I have some code like below
$("html").on("change", "input['data-href']", function() {
var href, obj, params;
obj = $(this);
href = obj.attr('data-href');
params = {};
params[obj.attr('data-param')] = obj.val();
return $.post(href, params);
});
The intention is that I can use form elements anywhere and have them auto
submit their value via ajax to the specified URL. However that is irrelevant
to the problem. The problem is that the code is detecting the change event
on any input element and not only elements with matching selector input[‘data-href’]
Is there some subtle issue with $().on that I am not addressing?
Attribute names may not be quoted. Use:
When your attribute contains special characters, a double slash can be used to escape it: