From 57dd7823753cfcc153f9393521b277ef0a87b69d Mon Sep 17 00:00:00 2001 From: Catouse Date: Tue, 12 Aug 2014 13:20:38 +0800 Subject: [PATCH] * updated template. --- src/js/template.js | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/src/js/template.js b/src/js/template.js index 92de7d4bb..49cf14336 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](); }); -- GitLab