0

I use the JQuery plug-in Messi to display some alert boxes.

I want to go on the previous page when I click on the "Yes" button:

$('#yes-no-cancel-buttons').on('click', function() {
        new Messi('Voulez-vous vraiment annuler toutes les modifications effectuées ?', {title: 'Retour', modal:true, buttons: [{id: 0, label:
    'Yes',  val: 'Y', btnClass: 'btn-danger'}, {id: 1, label: 'No', val:
    'N', btnClass: 'btn-success'}, ]});     
 });

Unfortunately I just begin in Javascript and Jquery and don't really know how to do this.

4

1 回答 1

1

您需要为callback选项对象提供一个属性:

new Messi('Voulez-vous vraiment annuler toutes les modifications effectuées ?',
    {
      title: 'Retour', modal: true,
      buttons: [
        {id: 0, label: 'Yes', val: 'Y', btnClass: 'btn-danger'},
        {id: 1, label: 'No', val: 'N', btnClass: 'btn-success'}],
      callback: function(val) { if(val == "Y") { history.back(); } }; }
    }
);

回调函数接收单击按钮的值(在本例中为'Y''N')作为其第一个参数,您可以使用条件来决定是否返回。

于 2012-11-06T14:30:30.133 回答