views:

34

answers:

1

I'm using jQuery Validate & Fancybox together on a website to load a modal Fancybox window on form submission (after being validated by Validate) to confirm an order is being processed but have encountered a weird issue I'm unable to resolve. The < a > tag is as follows on the same page as the form:

<a href="<?=ssl_url()?>basket/processing" class="processing" id="submit_holder">PROCESSING</a>

In the JS file I have the following config for Fancybox:

$(".processing").fancybox({
    'padding'       : 0,
    'width'  : 400,
    'height' : 400,
    'modal'         : true,
    'overlayColor'  : '#fff',
    'overlayOpacity': 0.8,
    'autoScale'     : true,
    'type'  : 'iframe',
    'transitionIn' : 'fade',
    'transitionOut' : 'fade',
    'titlePosition' : 'inside'
});

Now, clicking this link directly works fine - loads as expected. When trying to launch via Validate's submitHandler:

       submitHandler: function(form) {
            $('#submit_holder').click();
            form.submit();
       }

The Fancybox itself loads but completely blank. I can't view any source nor can I open the frame in a new window, it's almost as if the href attribute of the < a> tag isn't being obtained as the iframe src by Fancybox.

Can anyone help? This is driving me completely nuts.

Thanks, Matt

A: 

Have you tried $('#submit_holder').trigger('click'); instead of $('#submit_holder').click(); and also try in other browsers to see if its a browser issue.

RobertPitt
Hi Robert, thanks for your prompt response.Yes, I have tried .trigger() and across multiple browsers (should have noted this originally) - the weird thing is that the box itself with the config loads it just doesn't load the source (the frame contents).
Matt
In your browser whilst on the page with the form, type into the URL Address the following `javascript: $('#submit_holder').click();` - This will tell me if the .Click() is failing or the `SubmitHander`
RobertPitt
That did launch the box correctly - interesting, any other ideas?
Matt
ok so now you know its not the Click() method. Remove the form.submit(); this will now tell me if the form event is disabling all other actions during submit! and make sure you use `return false;` to prevent the form from executing
RobertPitt