创建自定义jQuery插件:“pluginName不是函数”

时间:2014-03-03 10:18:45

标签: javascript jquery jquery-plugins

当我在文档中调用插件时,它工作正常。但是当我在按钮点击事件中做同样的事情时,我收到了一个错误 TypeError:jQuery(...)。coreFrame不是函数

有人对此有任何疑问吗?提前完成。

我的插件

(function($) {
    $.fn.coreFrame = function(dataObject, templateName) {

        if (dataObject.Error.Status == 200){
            var source   = $("#"+templateName).html();
            var template = Handlebars.compile(source);
            var actualTemplate    = template(dataObject);

            return $(this).html(actualTemplate);
        }else{  
            var notificationArray ={};
            notificationArray["type"]= "info-box-red";
            notificationArray["message"]= notificationDetails[0].msg;


            var source   = $("#error_template").html();
            var template = Handlebars.compile(source);
            var actualTemplate    = template(notificationArray);

            return $(this).html(actualTemplate);
        }   
    }

}(jQuery));




$(document).ready(function(){
  $("#station-list-container").coreFrame(obj ,list_template);
  **It's working like this.** 

  $("button").on("click",function(){
    $("#station-list-container").coreFrame(obj ,list_template);
    **It's NOT woking.** 
  });
});

0 个答案:

没有答案