yui3

How can I create a AlloyUI DiagramBuilder from the JSON returned by DiagramBuilder.toJSON()?

谁都会走 提交于 2020-01-16 04:12:08
问题 DiagramBuilder.toJSON() returns a JSON representation of the diagram. How can I use this JSON object to create a new DiagramBuilder with the same diagram? 回答1: You can pass the jsonData.nodes to the fields attribute of the DiagramBuilder : var diagramBuilderJSON = diagramBuilder.toJSON(); new A.DiagramBuilder({ fields : diagramBuilderJSON.nodes }).render(); 回答2: You can pass the result of DiagramBuilder.toJSON() to the fields parameter of the DiagramBuilder. See the example below. jsonData =

How to localize the alloyui scheduler component?

蓝咒 提交于 2020-01-11 10:22:08
问题 I am trying to fully localize the alloyui scheduler in French. Following this article: How can I get a localized version of a YUI 3 or AlloyUI component? the job is almost done. However I am still missing tips for two things: - I need the time format in the left column to be changed from 1-12am/pm to 1-24 - I don't succeed to localize the "All day" term in the left top corner (or at least a way to hide it). Any help will be welcome 回答1: To change to a 24 hour clock, you need to set the

How can I dynamically add rows and columns to a YUI dataTable

回眸只為那壹抹淺笑 提交于 2020-01-06 08:46:06
问题 I am trying to modify the the YUI sortable dataTable example to add rows and columns dynamically after the dataTable is created. My code looks like this: YUI().use("datatable-sort", function(Y) { var cols = [ {key:"Company", label:"Click to Sort Column A", sortable:true}, {key:"Phone", label:"Not Sortable Column B"}, {key:"Contact", label:"Click to Sort Column C", sortable:true} ], data = [ {Company:"Company Bee", Phone:"415-555-1234", Contact:"Sally Spencer"}, {Company:"Acme Company", Phone:

How can I normalise a JavaScript object to a DOM element with YUI3?

99封情书 提交于 2019-12-25 04:38:09
问题 YUI2's Dom.get accepts both a DOM element or an id string as a parameter. In YUI3, Y.one is the replacement for Dom.get but it only accepts CSS selectors, not DOM elements. Is there a simple way, using YUI3, to normalise a JavaScript object to a DOM element? 回答1: To support the same signature as YAHOO.util.Dom.get you could do something like this: var getNode = function(el) { return Y.one('#' + el) || new Y.Node(el); }; Here's an example of the function above in use. 回答2: According to the API

Iterating through nested objects/arrays

这一生的挚爱 提交于 2019-12-23 04:04:20
问题 I'm trying to iterate through an object that can have several levels of arrays. Eg. I start with: var htmlString = { "div": [{ "attributes": { "class": "myDivClass" }, "p": [{ "attributes": { "class": "myPClass" } }] }] }; Now let's add something else: var htmlString = { "div": [{ "attributes": { "class": "myDivClass" }, "p": [{ "attributes": { "class": "myPClass" }, "span": [{ "attributes": { "class": "mySpanClass" } }] }] }] }; The code I'm working on will have the same sort of shape as:

Iterating through nested objects/arrays

徘徊边缘 提交于 2019-12-23 04:04:09
问题 I'm trying to iterate through an object that can have several levels of arrays. Eg. I start with: var htmlString = { "div": [{ "attributes": { "class": "myDivClass" }, "p": [{ "attributes": { "class": "myPClass" } }] }] }; Now let's add something else: var htmlString = { "div": [{ "attributes": { "class": "myDivClass" }, "p": [{ "attributes": { "class": "myPClass" }, "span": [{ "attributes": { "class": "mySpanClass" } }] }] }] }; The code I'm working on will have the same sort of shape as:

YUI3: How would I trigger an event?

流过昼夜 提交于 2019-12-13 21:27:15
问题 Suppose I have a click event on a link/button/etc. var myButton = Y.one('.button'); myButton.on('click', function() { // code }); There is something else happening on the page that I want to trigger a click event on this button. How would I do this? I saw YUI3's fire() method, but it looked like that was designed for custom events. If I am supposed to use fire(), then will myButton.fire('click') work? (I'm looking for the equivalent of jQuery's .trigger() method, which works on DOM events or

Why would we not use JavaScript library on a CDN if the webpage is using SSL (https)?

不打扰是莪最后的温柔 提交于 2019-12-13 13:37:57
问题 For JavaScript libraries such as jQuery or YUI3, either Google or Yahoo are hosting the scripts on their CDN, and a YUI 3 Cookbook paragraph says: perhaps your pages use SSL, in which case loading remote resources is a bad idea, as it exposes your users’ secure information to the remote site I can only see that the CDN site must be well trusted, or else malicious JavaScript can be running on www.mycompany.com's webpages. But assuming the CDN sites (Google and Yahoo) are well trusted, why

JavaScript YUI3 using global variables?

别等时光非礼了梦想. 提交于 2019-12-12 09:46:39
问题 I can't work out how to update a global variable from within YUI3. Consider the following code: window.myVariable = 'data-one'; var yuiWrap = YUI().use('node',function(Y) { console.log(window.myVariable); // 'data-one' window.myVariable = 'data-two'; console.log(window.myVariable); // 'data-two' }); console.log(window.myVariable); // 'data-one' Can anyone explain this to me? It's causing me a lot of trouble. Why can window.myVariable be accessed but not properly updated from within a YUI3

How can I get a localized version of a YUI 3 or AlloyUI component?

旧街凉风 提交于 2019-12-12 01:45:18
问题 As an example, how could I render an AlloyUI scheduler which has the days in Japanese rather than English? 回答1: To access a localized version of a YUI 3 component you must use the YUI config object's lang property. When specifying a YUI sandbox, pass it the language code(s) which you want the component(s) to be localized for: YUI({ lang : 'ja-JP' }).use( // your code here... Here is a specific example with the AlloyUI scheduler: YUI({ lang : 'ja-JP' }).use('aui-scheduler', function(Y) { new Y