I have this and it's working:
function cancelFunction(targetid,e) {
if (targetid.substring(0,9) == "editinput") {
if (e.keyCode != 27) {
return;
}
var target = targetid.substring(10);
}
else
var target = targetid.substring(11);
// DO OTHER STUFF HERE
}
$(\'[id^=editinput]\').keypress(function(e) {
var targetid= $(this).attr("id");
cancelFunction(targetid,e);
});
$(\'[id^=canceledit]\').click(function() {
var targetid= $(this).attr("id");
cancelFunction(targetid,"");
});
What i want to know if it's this possible to merge keypress event on [id^=editinput] and click event on [id^=canceledit] in a single call with function declared after that?
I mean something like this (obviously wrong syntax):
$((\'[id^=canceledit]\').click)((\'[id^=editinput]\').keypress)(function(e) {
var targetid = $(this).attr("id");
if (targetid.substring(0,9) == "editinput") {
if (e.keyCode != 27) {
return;
}
var target = targetid.substring(10);
}
else
var target = targetid.substring(11);
// DO OTHER STUFF HERE
});