SitePoint Sponsor

User Tag List

Results 1 to 3 of 3

Hybrid View

  1. #1
    SitePoint Enthusiast
    Join Date
    Jan 2008
    Location
    Hessle, East Yorkshire UK
    Posts
    88
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Dialog Button Text Problem

    Hi all

    I am probably missing something simple here, I am using jQuery Dialog and I am trying to pass the Button text to the dialog function in the following manner:

    Code JavaScript:
    <script type="text/javascript">
        function showDialog($url, $title, $form_id, $buttontext) 
    	{
            $('<div>').dialog({
                modal: true,
                open: function ()
                {
                    $(this).load($url);
                },         
                height: 500,
                width: 700,
                title: $title,
                buttons: {
                    $buttontext: function() {
                        $($form_id).submit();
                        $( this ).dialog( "close" );
                    },
                    Cancel: function() {
                        $( this ).dialog( "close" );
                    }	
    			}
            });
     
     
    	};
     
    </script>

    And I am passing the following:

    Code HTML4Strict:
    <a href="#" onclick="showDialog('templates/dialogs/dialog.editcheckpoint.php', 'Edit Checkpoint', '#editcheckpoint', 'Update Checkpoint');\">Edit</a>

    This works all apart from the button text which remains as $buttontext where it should be 'Update Checkpoint'

    I am sure I am missing something obvious or doing something stupid! I use the same Dialog function for a number of different tasks in the interface so want to customize the button text as I do with the title etc.

    Thanks for any help

    Matt
    Last edited by digitalquill; Mar 8, 2013 at 10:13. Reason: Added Jquery

  2. #2
    SitePoint Enthusiast
    Join Date
    Jan 2008
    Location
    Hessle, East Yorkshire UK
    Posts
    88
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    For anyone else trying to do this I have managed it with this method:

    Code JavaScript:
        function showDialog($url, $title, $form_id, $buttontext, $cancel) 
    	{
    		var buttons = {};
    		buttons[$buttontext] = function() { $($form_id).submit(); $( this ).dialog( "close" ); }
    		buttons[$cancel] = function() {  $( this ).dialog( "close" ); }
     
            $('<div>').dialog({
    							modal: true,
    							open: function ()
    							{
    								$(this).load($url);
    							},         
    							height: 500,
    							width: 700,
    							title: $title,
    							buttons :buttons
           					 });
     
    	};

  3. #3
    Non-Member
    Join Date
    Mar 2013
    Location
    London
    Posts
    2
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by digitalquill View Post
    For anyone else trying to do this I have managed it with this method:

    Code JavaScript:
        function showDialog($url, $title, $form_id, $buttontext, $cancel) 
    	{
    		var buttons = {};
    		buttons[$buttontext] = function() { $($form_id).submit(); $( this ).dialog( "close" ); }
    		buttons[$cancel] = function() {  $( this ).dialog( "close" ); }
     
            $('<div>').dialog({
    							modal: true,
    							open: function ()
    							{
    								$(this).load($url);
    							},         
    							height: 500,
    							width: 700,
    							title: $title,
    							buttons :buttons
           					 });
     
    	};
    hey good tricks ii have go through with this and find its a good trick.Thanks!!!!!!!!


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •