vendredi 20 février 2015

After JQuery on() is called, embed javascript stops running


I've tried this several different ways, at one point I had the .on call isolated to one line of code, and put console.write() messages before and after, the write messages don't fire after the on() is called. Scripts after this script's tag work fine.


Javascript is 1.2. Maybe it's too old?



$("body").on("change", ".media_frm", function(e)
{

if(e.target.value.length == 0) return true; //if blank or undefined, it's okay
var filename = e.target.value.match(/([^<\>\:\"\/\\\|\?\*])+$/i)[0]; //get rid of erroneous filepath
var filetype = filename.match(/[^.]+$/i)[0]; //get extension after '.'
if($.inArray(filetype, allowedExtensions) === -1)
{
alert("Invalid File Type: " + filename);
e.target.value = "";
return false;
}
return true;

});


Like I said, I've also set the above to a function, and just called on() on the element directly, like:


$(elem).on("change", verifyFunction);


and everything after this line will stop running, just like how everything stops running with the above block of code.





Aucun commentaire:

Enregistrer un commentaire