0

I am trying to add a name(not the text shown) to a button on the bottom panel and can't find a way to do it.

This is what I have so far...

    $("#dialog-import-from-existing").dialog({
        title: "Import From Existing",
        autoOpen: false,
        modal: true,
        draggable: false,
        resizable: false,
        width: 500,
        height: 525,

            buttons: {
                **name : "SubmitButton",**
                "Import": function() {
                $('#CreateForm').submit();
                $(this).dialog('close');
            },
            "Cancel": function() {
                //Need to added the js files to Driver studio.
                //$("models-to-add-container").effect("explode");
                $(this).dialog('close');
            }
            }
        });

I'm trying to have this button with the name "SubmitButton".

Thanks in advance.

2 Answers 2

0

The button option has two APIs. You're using the original, simpler API of mapping the button label to a click function. You can also use an array of objects, which gives you much more control.

$( "#dialog-import-from-existing" ).dialog({
    ...
    buttons: [
        {
            name: "SubmitButton",
            text: "Import",
            click: function() {
                $( "#CreateForm" ).submit();
                $( this ).dialog( "close" );
            }
        },
        {
            text: "Cancel",
            click: function() {
                $( this ).dialog( "close" );
            }
        }
   ]
});

This API allows you to pass anything that can be passed to .attr() plus event handlers.

Sign up to request clarification or add additional context in comments.

Comments

0

Try:

$("#dialog-import-from-existing").dialog({
    ...
    open: function() {
        $(this).parent().find('.ui-dialog-buttonpane button:contains("Import")').
            attr('name', 'SubmitButton');
    }
});

(Refined from jQuery UI Dialog Button Icons)

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.