2016-05-13 13 views
1

ich diese Javascript-Methode haben eine jquery Bestätigungsdialogfeld setzen und ich möchte Jquery Dialogfeld zur Bestätigungwie für JavaScript-Methode

function editcart(id,code,stock_qw,stock_rtq,pack){ 
    if((stock_qw%pack) != 0){ 
      if(!x) return false;  
       } 
    } 

Ich habe dieses jquery dialogbox und ich bin etwas verwirren setzen, wie man es zusammen

$('<div></div>').appendTo('body') 
       .html('<div><h6>Yes or No?</h6></div>') 
       .dialog({ 
       modal: true, 
       title: 'message', 
       zIndex: 10000, 
       autoOpen: true, 
       width: 'auto', 
       resizable: false, 
       buttons: { 
        Yes: function() { 
         doFunctionForYes(); 
         $(this).dialog("close"); 
        }, 
        No: function() { 
         doFunctionForNo(); 
         $(this).dialog("close"); 
        } 
       }, 
       close: function (event, ui) { 
        $(this).remove(); 
       } 
      }); 
      //$('#msg').hide(); 

      function doFunctionForYes() { 
       alert("Yes"); 
       $('#msg').show(); 


      } 

      function doFunctionForNo() { 
      // alert("No"); 
       $('#msg').show(); 
      } 
       } 

hat jemand bessere idee, wie das funktioniert?

+0

Geben Sie 'id' auf' $ ('

') 'wie' $ ('
') 'und dann versuche es als '$ (" # dialog ") zu öffnen. dialog ('open');' –

Antwort

0

Was ist mit reinem JS Bestätigungsdialog?

confirm('Yes or no? ') ? doFunctionForYes() : doFunctionFotNo(); 
+0

nein ich will etwas elegantes.i habe schon versucht mit confirm() box – jdoe

0

Sie können versuchen, diese:

$('<div></div>').appendTo('body') 
    .html('<div><h6>Yes or No?</h6></div>') 
    .dialog({ 
     modal: true, title: 'message', zIndex: 10000, autoOpen: true, 
     width: 'auto', resizable: false, 
     buttons: { 
      Yes: function() { 
       doFunctionForYes(); 
       $(this).dialog("close"); 
      }, 
      No: function() { 
       doFunctionForNo(); 
       $(this).dialog("close"); 
      } 
     }, 
     close: function (event, ui) { 
      $(this).remove(); 
     } 
}); 

Beispiel: http://jsfiddle.net/3d7QC/1032/