JavaScript
- 4 ответа
- 0 вопросов
2
Вклад в тег
/**
* @method
* @desc Book#on - The method adds events that could be triggered by TC#trigger method
* @param {string} names - Names of the events
* @param {function} callback - Event handler
* @param {boolean} [triggerOnInit] - If equals to true then event handler will be triggered immediately
* @param {object} [context] - "this" context for the handler
* @returns {object} - self
* @example
* //Returns this
* this.on( 'change:x', function() {
* alert( 'x is changed' );
* });
* @example
* //Returns this too. Alert will be execuded in window context and show secons argument, that has been passed to .trigger method ('Hello world')
* this.on( 'ohmygosh', alert, window );
* this.trigger( 'ohmygosh', 'Hello world' );
* @example
* //Shows "bar" alert immediately and waits for triggering "foo" event
* this.on( 'foo', function() {
* alert( 'bar' );
* }, true )
*
*/
function on(names, callback, triggerOnInit, context) {
return 'blah';
}