我开发了一个jquery ui-plugin,并不能真正理解使用哪种方法.根据jquery ui文档,我应该使用_trigger来触发事件,这允许使用插件初始化处理程序
$("#id").pluginname({
click: function(){
//called when clicked
}
});
Run Code Online (Sandbox Code Playgroud)
但如果我后来想要为这次活动增加更多的听众,我找不到任何办法.我正在尝试使用jquery绑定,但这不起作用.例:
$("#id").bind("click", function(){
//This does not get fired on click if using _trigger
})
Run Code Online (Sandbox Code Playgroud)
到目前为止,我唯一的解决办法是解雇两者,但感觉有点奇怪.我的代码必须执行以下操作:
$("#id").pluginname({
click: function(){
//called when my plugin uses this._trigger('click')
}
}).bind(function(){
//called when my plugin uses this.element.trigger('click')
});
Run Code Online (Sandbox Code Playgroud)
我正在使用自定义事件,但并不认为这与提出这个问题有关.任何人都知道如何在使用_trigger()时使用事件链接?
我在mongodb中使用了一些聚合函数.
说我有这样的文件
[
{
_id: "1",
periods: [
{
_id: "12",
tables: [
{
_id: "121",
rows: [
{ _id: "1211", text: "some text"},
{ _id: "1212", text: "some other text"},
{ _id: "1213", text: "yet another text"},
]
}
]
},
{
_id: "13",
tables: [
{
_id: "131",
rows: [
{ _id: "1311", text: "different text"},
{ _id: "1312", text: "Oh yeah"}
]
}
]
}
]
},
{
_id: "2",
periods: [
{
_id: "21",
tables: [ …Run Code Online (Sandbox Code Playgroud)