Jquery dialog box plug-in Example

Source: Internet
Author: User

The detailed code has been uploaded to the resource.

Http://download.csdn.net/source/752922

  1. // Encapsulate a function to add different events to multiple buttons.
  2. Function confirmfun (txt, urlstr ){
  3. Confirm (txt, function (){
  4. Window. Location. href = urlstr;
  5. });
  6. }
  7. $ (Document). Ready (function (){
  8. // Original code.
  9. // $ ('# Confirmdialog input: eq (1)'). Click (function (e ){
  10. // E. preventdefault ();
  11. /// Example of calling the confirm Function
  12. /// You must use a callback function to perform the "yes" Action
  13. // Confirm ("second button, OK? ", Function (){
  14. // Window. Location. href = 'HTTP: // www.greatverve.cn /';
  15. //});
  16. //});
  17. // Extended code
  18. $ ('# Confirmdialog input: eq (1)'). Click (function (e ){
  19. E. preventdefault ();
  20. Confirmfun ('second button, OK? ', 'HTTP: // www.greatverve.cn /');
  21. });
  22. Alert ('Multiple functions can be executed in ready ');
  23. });
  24. $ (Document). Ready (function (){
  25. $ ('# Confirmdialog input: eq (0)'). Click (function (e ){
  26. E. preventdefault ();
  27. Confirmfun ('the first button, OK? ', 'HTTP: // www.greatverve.cn /');
  28. });
  29. Alert ('ready can be called multiple times. ');
  30. });
  31. Function confirm (message, callback ){
  32. $ ('# Confirm'). Modal ({
  33. Close: false,
  34. Overlayid: 'confirmmodaloverlay ',
  35. Containerid: 'confirmmodaliner iner ',
  36. Onshow: function (DIALOG ){
  37. Dialog. Data. Find ('. message'). append (Message );
  38. // If the user clicks "yes"
  39. Dialog. Data. Find ('. Yes'). Click (function (){
  40. // Call the callback
  41. If ($. isfunction (callback )){
  42. Callback. Apply ();
  43. }
  44. // Close the Dialog
  45. $. Modal. Close ();
  46. });
  47. }
  48. });
  49. }

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.