views:

2131

answers:

2

Hello All,

Im using Thickbox 3.1 with jQuery 1.3.2 with the Validation plugin and all works great when I run the pages individually but when I use Thickbox the page popup (As it should) but the validation on the page now doesn't work (Inside the Thickbox), any help on this would be great.

BTW the strange thing is that Thickbox looks to be working inside the thickbox but not the validation (Which is on the page itself).

Thanks, --Phill

Adding Code:

page1.html (JavaScript)

$(document).ready(function(){
            $("#page1Form").validate({
                rules: {
                    "field1": {
                        required: true,
                        digits: true
                    },
                    "field2": {
                        required: true
                    }
                },
                errorElement: "div"
            });                     
        });

index.html (Thickbox link)

<a href="page1.html" class="thickbox">Page 1</a>

I can view source on the Thickbox popup and I see all the JS code and libraries are there but it's not running the validation in the Thickbox Popup.

+1  A: 

I think the even handelers are being set on page load, so they aren't set on the thickbox generated html. Can't you set a callback to start the validationi after the thickbox ajaxloads the content?

CodeJoust
Thanks after looking into the callback I think it will work. for now I got the go ahead to use the iFrame which worked as expected. Thanks again.
Phill Pafford
A: 

Same here......the Thickbox Ajax call does not setup Validate properly. Even though it is present and the form elements can be found. However on a 2nd thickbox call the form gets validated. How can you "see" the click events (or valdiation) in firebug?

I need to test but I think it started with Jquery 1.3.2 - when I used TB/Validate/Form with 1.2.6 it worked.

you can download the webdeveloper tool bar for FireFox (its an add-on) and look at the frame source view
Phill Pafford
Use a tool like firebug and look into the javascript stack trace to find errors, and add breakpoints to find your problem.Also, if your using thickbox iframe, there might be a cross-domain problem (between static.yoursite.com and www.yoursite.com... or even another site), that would prohibit the manipulation of the iframe's DOM.
CodeJoust