jQuery UI Dialog buttons Demo

jQuery Code

  1. //do when the dom is ready
  2. jQuery(document).ready(function($) {
  3.     //loop through every button anchor element
  4.     $('.dialog_but').each(function() {
  5.         //create a local scope of a dialog variable to attach
  6.         var $dialog;
  7.  
  8.         //create the dialog for the div.dialog_content standing next to the anchor element
  9.         //we make the autoOpen false so that it can be reusable
  10.         //also we set the modal = true to appear the dialog as a modal prompt
  11.         $dialog = $(this).next('div.dialog_content').dialog({modal: true, autoOpen: false, width: 600});
  12.  
  13.         //add a wee bit of button thing
  14.         $(this).button({
  15.             icons: {
  16.                 primary: 'ui-icon-extlink'
  17.             }
  18.         });
  19.  
  20.         //now attach the open even of the dialog to the anchor element
  21.         $(this).click(function(e) {
  22.             //prevent the anchor element to go to the hyperlinked page
  23.             e.preventDefault();
  24.  
  25.             //open the dialog
  26.             $dialog.dialog('open');
  27.         });
  28.     });
  29. });

Dialog Buttons

  • Button 1
    This is Dialog One!
  • Button 2
    This is Dialog One!
  • Button BIG

    Another dialog prompt with a little bit More HTML

    Lorem ipsum dolor sit amet, consectetur adipiscing elit. Morbi et mauris erat. Morbi placerat semper sodales. Pellentesque sollicitudin quam id erat iaculis convallis eleifend odio aliquet. Aenean pulvinar adipiscing enim id sodales. Pellentesque tellus eros, interdum vel dignissim ac, dignissim sit amet dui. Integer felis augue, condimentum eget ullamcorper et, hendrerit at lacus. Nulla placerat ipsum at risus consectetur sit amet suscipit dui pellentesque. Sed sed elit a orci ornare posuere bibendum sodales turpis. Fusce euismod ante ut nunc pharetra facilisis. Nulla laoreet malesuada lacus, in sagittis urna adipiscing nec. Proin accumsan dolor vitae urna convallis non pretium odio convallis. Integer nisi lorem, varius in bibendum sit amet, scelerisque vel libero. Proin placerat pharetra congue. Sed tempus augue vitae nisl viverra hendrerit at nec purus. Vivamus laoreet erat vel turpis scelerisque at elementum sapien ultrices. Nulla at leo diam. Praesent hendrerit imperdiet ultricies. Curabitur vestibulum turpis in lacus faucibus convallis. Quisque nec magna nulla.