Jquery Ui dialog on form submit -
i'm trying stop jquery ui dialogs popping after 1 condition met on form submit. 1 dialog per event i'm looking for. kind of break if condition met. dialogs come after 1 closed. tried stoppropagation , stopimmediatepropagation no effect. code follows:
$('#myform').on('submit',function(e){ if ($("#trama").is(':checked') && !$('.tramachecked:checked').length) { $( "#trama-message" ).dialog({ modal: true, draggable: false, resizable: false, buttons: { ok: function() { $( ).dialog( "close" ); } } }); e.preventdefault(); } if ($("#tramb").is(':checked') && !$('.trambchecked:checked').length) { $( "#tramb-message" ).dialog({ modal: true, draggable: false, resizable: false, buttons: { ok: function() { $( ).dialog( "close" ); } } }); e.preventdefault(); } });
html:
<div id="tramb-message" title="warning"> <p> <span class="ui-icon ui-icon-alert" style="float:left; margin:3px 7px 50px 0;"></span> selected "tram b hall" did not select tram option! </p> </div> <div id="trama-message" title="warning"> <p> <span class="ui-icon ui-icon-alert" style="float:left; margin:3px 7px 50px 0;"></span> selected "tram hall" did not select tram option! </p> </div>
changing e.preventdefault(); return false; did trick.