插件调用者中的 jQuery 方法
我正在编写我的第一个 jQuery 插件,但遇到了一些障碍。基本上,这是我希望插件调用者执行的操作,但我不确定如何构建插件:
$('div.selector').myPlugin(
'dataloader', {
{
source : 'source.json',
autoUpdate : true
},
buildComplete : function() {
//Do something when the building is completed
}
});
因此,基本上,“dataloader”值是必需的,大括号内的选项是可选设置,并且buildComplete 是一个在某件事完成后执行的函数。
我不确定如何在插件调用者中实现“buildComplete”函数(或类似函数)。我希望避免使用下面所示的方式,因为“buildComplete”对于使用的每个页面都会有所不同:
//No can do!
$('div.selector').myPlugin('dataloader').buildComplete('do something');
是否有一个基本示例,我可以在其中找到相关内容?
谢谢, 斯普里诺724
I am writing my first jQuery plugin and I ran into a few speed bumps. Here is what I would like my plugin caller to do, basically, but I'm not sure how to structure the plugin:
$('div.selector').myPlugin(
'dataloader', {
{
source : 'source.json',
autoUpdate : true
},
buildComplete : function() {
//Do something when the building is completed
}
});
So, basically, the "dataloader" value is required, the options inside of the curly braces are optional settings, and the buildComplete is a function which is executed once something has been completed.
I'm not sure how to implement a "buildComplete" function (or the like) into the plugin caller. I would like to avoid the way shown below, since "buildComplete" would be different for each page it is used:
//No can do!
$('div.selector').myPlugin('dataloader').buildComplete('do something');
Is there a basic example where I could find something on this?
Thanks,
spryno724
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
这应该可以帮助你开始
This should get you started