views:

819

answers:

2

I have this function

   jQuery("form#add_cv").submit ( function(){ 
    if (Spry.Widget.Form.validate(this) == true){

            jQuery("#show_rules").fancybox({
                'padding'       : 0,
                'autoScale'     : false,
                'autoDimensions': false,
                'transitionIn'  : 'none',
                'transitionOut' : 'none',
                'width'     : 600,
                'height'        : 450,
                'titlePosition'     : 'inside',
                'scrolling' : 'no'
            }).trigger('click'); 

            jQuery('div#sb_buttons button#cancel_submit').click(function() { 
                $.fancybox.close();
                return false;
            });


            jQuery('div#sb_buttons button#submit_form').click(function() { 
                jQuery("form#add_cv").submit("true");
                $.fancybox.close();
                return true;
            });

        return false;
    }
});

On clicking on ok button

            jQuery('div#sb_buttons button#submit_form').click(function() { 
                jQuery("form#add_cv").submit("true");
                $.fancybox.close();
                return true;
            });

, from fancybox window . Form from actual page is submitting , and fancybox window is closing then the submit function is repeating again , how can i solve the problem ... sorry for this kind of question ... but i don't have idea what to do , and sorry for my English , hope you will understand me :) Thanks

A: 

It appears to me that when you click submit you are telling jQuery to submit the form and close your fancybox. Then assuming your submit button is actually type=submit, it's inherent behaviour takes over and it submits the form.

Why don't you try removing the line jQuery("form#add_cv").submit("true"); from your submit function?

codemonkeh
I removed it , and no reaction , i wasted a lot of time trying a different methods , and no idea , help please
mIRU
A: 

After some good hours of searching , i finally solved the problem , and big thx to Xian for help also.

this is the result :

    jQuery("form#add_cv").submit ( function(){ 

    if( typeof( accept ) != 'undefined' ){
        if(accept){ return true }
    }


    if (Spry.Widget.Form.validate(this) == true){

            jQuery("#show_rules").fancybox({
                'padding'       : 0,
                'autoScale'     : false,
                'autoDimensions': false,
                'transitionIn'  : 'none',
                'transitionOut' : 'none',
                'width'     : 600,
                'height'        : 450,
                'titlePosition'     : 'inside',
                'scrolling' : 'no'
            }).trigger('click'); 


            jQuery('div#sb_buttons button#cancel_sb').click(function() { 
                $.fancybox.close();
                return false;
            });

            jQuery('div#sb_buttons button#sb_form').click(function() {
                accept=true;
                $.fancybox.close(); 
                return  true;
            });


         return false;   
    }


});

i added this line of code

    if( typeof( accept ) != 'undefined' ){
        if(accept){ return true }
    }

after clicking the ok button , i declared that accept is true , after form can be submitted , thanks to all that tried to help me ;)

mIRU