jquery - Adding logic on the Cancel/Ok modal popup window click,Foundation 5 Modal -
i trying figure out silly thing work couple of hours,but doesnt seem working.i got foundation 5 modal alert window working javascript.i have prevent delete operation if user clicks on cancel button(on alert) , delete if click on ok or cross(x) icon right. here mark , javascript that
<div class="reveal-modal small" id="firstmodal" data-reveal> <p>are sure?</p> <a href="#" class="close-reveal-modal" id="alert-close">×</a> <a href="#" class="button alert" id="alert-cancel">cancel</a> <a href="#" class="button alert" id="alert-ok">ok</a> </div>
and javascript
$('#firstmodal').foundation('reveal', 'open');
i tried adding callback after 'open' doesnt seem working.also tried catching cancel/ok buttons click event using jquery.none of them works.now data gets deleted ,no matter button user chooses edit: have tried this,but not working oout well
$('#firstmodal').foundation('reveal', 'open', function (value) { if (value) { modifyselectlist(id, currentdefaultid); } else { $('#firstmodal').foundation('reveal', 'close'); } });
please in advance
i got working adding following code(i removed close (x) button top right corner(might helpful me)
function revealmodal(callback) { $('[data-reveal]').foundation('reveal', 'open', {}); $(document).on('opened.fndtn.reveal', '[data-reveal]', function () { //handle ok click $('#alert-ok').click(function () { callback.call(options); $('[data-reveal]').foundation('reveal', 'close'); }) //handle cancel click $('#alert-cancel').click(function (event) { //your logic here $('[data-reveal]').foundation('reveal', 'close'); }) }) } function callback(options){ //yor application logic }
Comments
Post a Comment