Javascript 创建自定义jQuery插件:";pluginName不是一个函数;

Javascript 创建自定义jQuery插件:";pluginName不是一个函数;,javascript,jquery,jquery-plugins,Javascript,Jquery,Jquery Plugins,当我调用文档中的插件ready时,它工作正常。但是当我在按钮点击事件中做同样的事情时,我得到了一个错误 类型错误:jQuery(…)。coreFrame不是函数 有人知道这件事吗?提前准备好 我的插件 (function($) { $.fn.coreFrame = function(dataObject, templateName) { if (dataObject.Error.Status == 200){ var source = $("

当我调用文档中的插件ready时,它工作正常。但是当我在按钮点击事件中做同样的事情时,我得到了一个错误 类型错误: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.** 
  });
});

你能在a中重现这个问题吗?我们需要查看页面的HTML,这个错误意味着当你调用coreFrame时插件还没有加载。嗯,好的,给我一秒钟,你的代码片段正确吗?在中有一个额外的
函数()code@DarkoRomanov如果它在DOM就绪处理程序中工作,而不是在click事件处理程序中工作,那么问题不在于它尚未加载。