EasyUI Forum

General Category => EasyUI for jQuery => Topic started by: alex.capurro on February 08, 2012, 05:24:40 AM



Title: create dialog from script
Post by: alex.capurro on February 08, 2012, 05:24:40 AM
Hi,

im trying to create a dialog with two buttons (yes, no) from script. The examples on the site already have a the pop visible with divs. Basically when a user clicks on a link on my site i want the dialog to appear.

So far I can do that by using this:

Quote
$.messager.confirm('Unsaved Changes', 'Save before proceeding?', function(r){
            if (r){
               //user said yes
               alert('confirmed:'+r);
            } else {   
               //user said no, so do not save and redirect
               parent.location.href = requestedLink;
            }

However what I would like to know is how do i tell it to show a 'yes' button and a 'no' button? Obviously the dialog should only be shown when the user clicks on a link on my site.. The documentation does not seem to show this, neither does the demo.

Thanks


Title: Re: create dialog from script
Post by: alex.capurro on February 08, 2012, 06:56:06 AM
ok problem solved. This is what i ended up doing:

Quote
$(function(){
      $('#dd').dialog({
         closed:true,
         title:'Unsaved Changes',
         buttons:[{
            text:'Yes',
            iconCls:'icon-ok',
            handler:function(){
               //do something
            }
         },{
            text:'No',
            handler:function(){
               //do not save but go to link requested
               $('#dd').dialog('close');
            }
         },{
            text:'Cancel',
            handler:function(){
               //do nothing
               $('#dd').dialog('close');
            }
         }]
      });
   });

I still needed to have a predefined div, but i just set it to closed in the code above.