diff --git a/src/js/template.js b/src/js/template.js index 92de7d4bb7b0bdb37ee950aa5d766b6c42f1b773..49cf143368cc2cf33fb17914e0f9f48177270fb5 100644 --- a/src/js/template.js +++ b/src/js/template.js @@ -2,12 +2,14 @@ +function($, window, document, Math) { "use strict"; + var name = 'zui.$componentObject$'; var $ComponentName$ = function(element, options) { + this.name = name; this.$ = $(element); - this.getOptions(options); + this.getOptions(options); this.init(); }; @@ -21,17 +23,23 @@ $ComponentName$.prototype.init = function() { // ... - } + }; + + $ComponentName$.prototype.callEvent = function(name, params) + { + var result = this.$.callEvent(name + '.' + this.name, params, this); + return !(result.result != undefined && (!result.result)); + }; $.fn.$componentObject$ = function(option) { return this.each(function() { var $this = $(this); - var data = $this.data('zui.$componentObject$'); + var data = $this.data(name); var options = typeof option == 'object' && option; - if (!data) $this.data('zui.$componentObject$', (data = new $ComponentName$(this, options))); + if (!data) $this.data(name, (data = new $ComponentName$(this, options))); if (typeof option == 'string') data[option](); });