Sunday, 15 August 2010

Bootstrap - how to make modal not showing if the condition is false when clicking the button -



Bootstrap - how to make modal not showing if the condition is false when clicking the button -

in web project using bootstrap. goes smoothly except 1 case below:

in 1 page there button. when clicked js function invoked checking. if checking fails, hope alert message box shows up. both alert box , modal div box show. can help? lot!

below code using:

button:

class="lang-html prettyprint-override"><button id="setpropertiesdivbutton" type="button" class="btn btn-default" data-toggle="modal" data-target="#setpropertiesdiv" onclick='showsetpropertiesdiv(-1)'>add properties</button>

modal div:

class="lang-html prettyprint-override"><div class="modal fade" id="setpropertiesdiv"> ........ </div>

js function:

class="lang-js prettyprint-override">function showsetpropertiesdiv(pageindex) { if (!checkobjisnull($("#oldprice"))) { top.dialog_alert("please set price!"); $("#setpropertiesdiv .modal-dialog .modal-content .modal-footer .btn.btn-primary").hide(); //$('#setpropertiesdiv').modal('hide'); //$("#setpropertiesdiv .modal-dialog .modal-content .modal-footer .btn.btn-primary").modal('hide'); homecoming false; } }

your button fires 2 events: opening modal (bootstrap event) , event.

remove 'data-...' attributes button (this open modal), remove code hides modal in javascript , open modal

html:

<button id="setpropertiesdivbutton" type="button" class="btn btn-default" onclick='showsetpropertiesdiv(-1)'>add properties</button>

js:

function showsetpropertiesdiv(pageindex) { if (!checkobjisnull($("#oldprice"))) { top.dialog_alert("please set price!"); homecoming false; } else { $('#setpropertiesdiv').modal(); } }

twitter-bootstrap bootstrap-modal

No comments:

Post a Comment