jzaefferer/jquery-validation — Issue #307: Issue with findByName function with iframes
Author: CameronJ
Created: 2012-01-26 18:50:14+00:00
State: open

I'm not entirely sure how I can explain this problem, but I'll do my best. I am currently using an iframe (both on the same domain), and from inside the iframe, I'm calling the validation script on a from resting inside jquery ui dialog outside the iframe. I assume that my issue arose because of the inside to outside the iframe jumping, but perhaps that's not really the problem.

It is important to note, that all of the validation functions that I have tested work perfectly EXCEPT remote. It throws a js error that "element" is undefined. I tracked this error back to the findByName function. I was able to solve the problem by making a change to the findByName function to the following:

findByName: function( name ) {
// select by name and filter by form for performance over form.find("[name=...]")
var form = this.currentForm;
return $(form).find("[name='" + name + "']");
},

I realize that you used map because of a performance enchancement; however, the document.getElementsByName(name) is returning null. I assume this is because document is referring to the code inside the iframe where this.currentForm is referring to the location of the actual form (outside the iframe).