admin管理员组文章数量:1300135
If this is the equivalent to the jquery bind method, what would it be for the trigger method.
function bind( scope, fn ) {
return function () {
fn.apply( scope, arguments );
};
}
the code above is from another post and it looks the same as a proxy method
you can ment on this too
I have to take the jquery part out off this framework, - this is just the relevant part
if (selector === '') {
this.el.bind(eventName, method);
} else {
this.el.delegate(selector, eventName, method);
}
}
}
});
if (includes) result.include(includes);
return result;
};
exports.Controller = mod;
})($, window);
var exports = this;
var Events = {
bind: function(){
if ( !this.o ) this.o = $({});
this.o.bind.apply(this.o, arguments);
},
trigger: function(){
if ( !this.o ) this.o = $({});
this.o.trigger.apply(this.o, arguments);
}
};
thanks
If this is the equivalent to the jquery bind method, what would it be for the trigger method.
function bind( scope, fn ) {
return function () {
fn.apply( scope, arguments );
};
}
the code above is from another post and it looks the same as a proxy method
you can ment on this too
I have to take the jquery part out off this framework, - this is just the relevant part
if (selector === '') {
this.el.bind(eventName, method);
} else {
this.el.delegate(selector, eventName, method);
}
}
}
});
if (includes) result.include(includes);
return result;
};
exports.Controller = mod;
})($, window);
var exports = this;
var Events = {
bind: function(){
if ( !this.o ) this.o = $({});
this.o.bind.apply(this.o, arguments);
},
trigger: function(){
if ( !this.o ) this.o = $({});
this.o.trigger.apply(this.o, arguments);
}
};
thanks
Share Improve this question edited Jul 24, 2013 at 12:01 Richard asked Jul 24, 2013 at 11:45 RichardRichard 4,54611 gold badges62 silver badges89 bronze badges 3- 3 That code is not at all related to the jQuery bind method. – Barmar Commented Jul 24, 2013 at 11:48
- oh, do you have a solution, suggestion – Richard Commented Jul 24, 2013 at 11:50
- 1 See stackoverflow./questions/2490825/… – d4rkpr1nc3 Commented Jul 24, 2013 at 11:54
2 Answers
Reset to default 8It depends on the type of event you wish to trigger. If it's a custom event:
var event = new Event('build');
elem.dispatchEvent(event);
If it's a native event:
var event = new MouseEvent('click');
elem.dispatchEvent(event);
This is of course meant to simulate a mouse event. Other events have their own type.
Once I crossed this site How to Manually Trigger Events in JavaScript
// Here is a VERY basic generic trigger method
function triggerEvent(el, type)
{
if ((el[type] || false) && typeof el[type] == 'function')
{
el[type](el);
}
}
// We could call this on multiple objects at any time
function resetFields()
{
triggerEvent(document.getElementById('has-email'), 'onchange');
triggerEvent(document.getElementById('other-field'), 'onclick');
triggerEvent(document.getEleemntById('another-one'), 'onblur');
}
本文标签: javascript equivalent to jquery trigger methodStack Overflow
版权声明:本文标题:javascript equivalent to jquery trigger method - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741657137a2390823.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论