Reputation: 1756
I have created a couple of custom events, "check" and "uncheck". I can easily use jQuery to implement these like this:
$("input:checkbox,input:radio").on("click",function(){
if (j$(this).is(":checked")) {
j$(this).trigger({
type: "check"
});
} else {
j$(this).trigger({
type: "uncheck"
});
}
});
How can I allow for inline binding of this event?
<input type="checkbox" oncheck="fee('arg1','arg2')" onuncheck="fi('arg1','arg2')" />
Edit
My start to implement this could be somewhere along the lines of this:
$("[oncheck]").each(function(){
$(this).on("check",function(){
eval($(this).attr("oncheck"));
});
});
$("[onuncheck]").each(function(){
$(this).on("uncheck",function(){
eval($(this).attr("onuncheck"));
});
});
However, although I know it would work, I'm very opposed to using eval
for this.
Upvotes: 1
Views: 168