Return false after prompt but continue with script

Return false after prompt but continue with script

Hi all,

I have a click function which firstly opens a prompt dialog, calls an ajax script and then proceeds to the second part of the function.

By adding a return false; after the prompt the script it unable to proceed to step 2. 

Does anybody have a better way of doing what Im trying to do?

  1. $("#btn_next").click( function(event){

  2. var form_values = $('#content_form [name^="data"]').serialize();
  3. var url = $(this).attr('href');
  4. var action = $('#content_form').attr('action');

  5. // Step 1
  6. if( $('body').hasClass('template-informationform') ){

  7.       bootbox.confirm("Do you need to blah blah?", "No", "Yes", function(result) {
  8.             var skip = false;
  9.             if (! result){
  10.                   skip = true;
  11.             }
  12.             $.post('/content/ajaxskipcontent', {data: skip});
  13.       });
  14. return false;
  15. }

  16. // Step 2
  17. if (form_values.length > 0) {
  18.       $.post(action, {data: form_values}, function(result) {
  19.             if (result=='success') {
  20.                 window.location.href = url;
  21.             }else{
  22.                   alert('Unable to save content');
  23.             }
  24.       });
  25.       return false;
  26. }

  27. });