Execute JavaScript function on a dynamic element (AJAX).
- by jartaud
Hello i have this following function:
... var model = $("#carModel");
.... model.change(validModel);
function validModel(){
if(model.val() == undefined){
model.addClass("errorJS");
return false;
}else{
model.removeClass("errorJS");
return true;
}
}
I am getting carmodel id from a select box generated after an AJAX call. I can get its value in the Firebug console, but the function doest not execute. Even tough i use model.livequery(validModel);
// The errorJS class put a red border in a element, if the function returns false