Alert with Option Buttons in the Window Body – jQueryUI in a Salesforce Custom Button

5 Nov

Here is another example of using jQueryUI in a Salesforce custom button. I’m referencing Super Clone Pro pages that use different configurations for cloning in this example. This could easily be adapted for other pages or actions. Enjoy!

jqueryui-modal-dialog-with-option-buttons

{!REQUIRESCRIPT('//ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js')} 
{!REQUIRESCRIPT('//ajax.googleapis.com/ajax/libs/jqueryui/1.11.3/jquery-ui.min.js')} 
 
var $j = jQuery.noConflict(); 
$j(function() {
      var winHead = '' +
                    '';
      var winBody = '';

      $j('head').append(winHead); 
      $j('body').append(winBody); 
      $j("#clone-dialog").dialog({ 
        autoOpen: true, 
        modal: true,
        width: 500,
        buttons: { 
            "Cancel":  function() {$j(this).dialog("close");}
        } 
    }); 

      $j( "#clone-op" ).button().on( "click", function() {
        window.location.href = '/apex/lcrm-scp__scpclone?rid={!Account.Id}&cfg=StandardClone';
      });
      $j( "#copy-from-op1" ).button().on( "click", function() {
        window.location.href = '/apex/lcrm-scp__scpclone?rid={!Account.Id}&cfg=CloneOpt1';
      });
      $j( "#copy-from-op2" ).button().on( "click", function() {
        window.location.href = '/apex/lcrm-scp__scpclone?rid={!Account.Id}&cfg=CloneOpt2';
      });
      $j( "#copy-from-op3" ).button().on( "click", function() {
        window.location.href = '/apex/lcrm-scp__scpclone?rid={!Account.Id}&cfg=CloneOpt3';
      });
      $j( "#copy-to-op1" ).button().on( "click", function() {
        window.location.href = '/apex/lcrm-scp__scpcopy?rid={!Account.Id}&cfg=CopyOpt1';
      });
      $j( "#copy-to-op2" ).button().on( "click", function() {
        window.location.href = '/apex/lcrm-scp__scpcopy?rid={!Account.Id}&cfg=CopyOpt2';
      });
      $j( "#copy-to-op3" ).button().on( "click", function() {
        window.location.href = '/apex/lcrm-scp__scpcopy?rid={!Account.Id}&cfg=CopyOpt3';
      });

});