javascript - Before Unload keeps firing -


i'm having trouble dealing before unload event, which, reason, keeps firing when explicitly tell no to.

so, html:

<div class="payment-details-account-top">     <form id="payment-details-form-card" action="<?php echo mage::geturl('orderform/index/changedpayment'); ?>" method="post">         <div class="row all-steps">             <div class="col-md-12">                 <input type="radio" name="payment-with-card" value="<?php echo $this->__('betale med kort') ?>" id="payment-with-card" class="css-checkbox" <?php if ($ba->getmethodcode() == 'payex2'): ?> checked <?php endif; ?> onclick="this.form.submit();">                 <label for="payment-with-card" name="payment-with-card" class="css-radio-label"></label>                 <input type="submit" name="payment-with-card" id="payment-with-card" value="<?php echo $this->__('betale med kort') ?>" class="top-payment-buttons" />             </div>         </div>     </form> </div> <div class="payment-details-account-bottom">     <div class="row all-steps">         <div class="col-md-12">             <input type="radio" name="payment-with-faktura" value="<?php echo $this->__('betale med faktura') ?>" id="payment-with-faktura" class="css-checkbox" <?php if ($ba->getmethodcode() != 'payex2'): ?> checked <?php endif; ?> >             <label for="payment-with-faktura" class="css-radio-label"></label>             <input type="button" name="payment-with-faktura" id="payment-with-faktura" value="<?php echo $this->__('betale med faktura') ?>" class="bottom-payment-buttons" />             <form id="payment-details-form" action="<?php echo mage::geturl('orderform/index/changedpayment'); ?>" method="post">             </form>         </div>     </div> </div> 

in order change selected form, use radio buttons along labels style radios according needs. so, here's jquery:

$('#payment-with-faktura').on('click', function(){     $('#payment-with-card').removeattr("checked");     $('#payment-with-faktura').prop("checked", true);     $(window).unbind("beforeunload"); });  $('#payment-with-card').on('click', function(){     $('#payment-with-faktura').removeattr("checked");     $('#payment-with-card').prop("checked", true);     $(window).unbind("beforeunload"); }); 

none of seems working, went ahead , added this

$('.css-radio-label').on('click', function () {     $(window).unbind("beforeunload"); }); 

the result still same, whenever change selected radio , try, example, refresh page, i'm getting popup alerting i'm leaving page , asking if wish stay on page or leave page.

so, doing wrong here?

best regards


Comments

Popular posts from this blog

c# - Validate object ID from GET to POST -

node.js - Custom Model Validator SailsJS -

php - Find a regex to take part of Email -