Adrian
Adrian

Reputation: 2291

Break event untill click and after continue jquery

I need to break an event that i submitted and when it breaks a popup will come, after I click the button I understood then it will continue to the rest of the code to execute it.

Jquery

$(document).ready(function() {
  $("#search_cerf").submit(function(e){
    e.preventDefault();
    $('.site-content-area').html('Some Stuff done');
    // Popup comes up and we stop here
    $('.container .site-content-area').append('<div class="popup-thank-you" style="display: block;"><h2>ERROR</h2><span class="message-popup">THE BIG MESSAGE</span><br><br><br><button id="gotit" class="gotitval">I understand. Please validate now</button></div>');
    // after users click I understood please validate now it shoul continue to next step
      $('.container').on('click', '.gotitval', function(event) {
        $('.popup-thank-you').remove();
      });
    // do some other stuff ajax related
    alert ('script had finished');
  });
});

Upvotes: 0

Views: 119

Answers (1)

ukung
ukung

Reputation: 410

Move you alert script

$(document).ready(function() {
  $("#search_cerf").submit(function(e){
    e.preventDefault();
    $('.site-content-area').html('Some Stuff done');
    // Popup comes up and we stop here
    $('.container .site-content-area').append('<div class="popup-thank-you" style="display: block;"><h2>ERROR</h2><span class="message-popup">THE BIG MESSAGE</span><br><br><br><button id="gotit" class="gotitval">I understand. Please validate now</button></div>');
    // after users click I understood please validate now it shoul continue to next step
      $('.container').on('click', '.gotitval', function(event) {
        $('.popup-thank-you').remove();
        alert ('script had finished');
      });
  });
});

Upvotes: 2

Related Questions