broadcast is 0, the event is received only by objects in the event’s bubble tree. A
value of 1 means that YUI also broadcasts the event to the top-level Y object, which
means Y.on() can handle the custom event. A value of 2 means that the event is
also broadcast to the Y.Global object, which means any YUI instance on the page
can respond to the event. Events fired from an EventTarget have a default broadcast
of 0.
One subtle point to think about is whether to define event behavior for an entire class,
or only for particular instances. In the example, CommandModule and MissionControl set
their event listeners in their own initializer() function, which ensures that all instances
of CommandModule listen for eagle:joke. To define an event listener only for
a particular instance of CommandModule, you could call commandModule.on() in the
YUI().use().
Example 5-12. Scraping HTML with YQL
用YQL做部分页面抓取:
http://developer.yahoo.com/yql/guide/yql-select-xpath.html#html_table-using_xpath
var query = 'select * from html where url="{url}" and xpath="{xpath}"',
params = {};
params.url = 'http://kleinbottle.com/specs_for_nice_klein_bottles.htm';
params.xpath = '//table[1]/tr';
query = Y.Lang.sub(query, params);
响应式设计很赞
Example 6-6. Using Grids for responsive design