Execute JavaScript function on a dynamic element (AJAX).

Posted by jartaud on Stack Overflow See other posts from Stack Overflow or by jartaud
Published on 2010-06-08T04:51:56Z Indexed on 2010/06/08 5:02 UTC
Read the original article Hit count: 474

Filed under:
|
|
|

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

© Stack Overflow or respective owner

Related posts about JavaScript

Related posts about jQuery