【发布时间】:2014-11-27 00:22:52
【问题描述】:
我是创建 jquery 插件的新手,我使用淘汰赛绑定创建了它以更加动态,并且它工作正常,但我需要访问应用于 HTML 元素的实例的淘汰赛视图模型,我该怎么做?
(function ($) {
$.fn.CFITGrid = function (options) {
return this.each(function () {
var defaultOpthions = {
// here default options values
};
var settings = $.extend({}, defaultOpthions, options);
function CFITGridViewModel() {
// class I will use it
}
var CFITGridViewModelObject = new CFITGridViewModel(); // Variable I need to access
// do somthing
});
}})(jQuery);
//In the page
$(document).ready(function () {
$("#Datadiv").CFITGrid({
DefaultLoadDataUrl: "api/apiUserInfo/GetList?pageNumber=" + 1,
DefaultPropertiesName: ["FirstNme", "LastName", "UserName"],
});
// I need to access the instance of the plugin and variable which inside it here
});
【问题讨论】:
-
我需要在应用后访问创建的 CFITGrid 实例及其变量
-
您的问题中有很多代码,其中大部分可能与实际问题无关。您能否更新您的问题,去除所有不需要的部分,也许向我们展示您到目前为止所做的尝试,以便问题变得更加明显/具体?也许把它变成repro 也会有所帮助。
-
你是对的,我做到了,谢谢 Jeroen
标签: javascript jquery knockout.js