Skip to main content

Search and Top Navigation

#10714 closed bug (notabug)

Opened December 03, 2014 10:22PM UTC

Closed December 03, 2014 11:26PM UTC

Last modified December 04, 2014 02:01PM UTC

Dialog with button created using the array definition cause an error on button click.

Reported by: DaazKu Owned by:
Priority: minor Milestone: none
Component: ui.dialog Version: 1.11.2
Keywords: Cc:
Blocked by: Blocking:
Description

I'm getting an error on button clicks when using the buttons array definition feature in dialog.

Note that I'm using $('<div></div>').dialog() but using a pre-existing DOM element doesn't change anything

http://jsfiddle.net/rd1r63c9/3/ $('<div></div>').dialog()

http://jsfiddle.net/rd1r63c9/4/ $('#test').dialog()

P.S. Sorry for putting all the code in the HTML section but the external ressource would not load and cause errors for some obscure reasons

Attachments (0)
Change History (4)

Changed December 03, 2014 11:26PM UTC by scottgonzalez comment:1

resolution: → notabug
status: newclosed

That's because you're passing undefined as the click property (you're executing the noop).

Changed December 04, 2014 01:33PM UTC by DaazKu comment:2

_comment0: Replying to [comment:1 scott.gonzalez]: \ > That's because you're passing `undefined` as the `click` property (you're executing the noop). \ \ Sorry! My bad.... \ I was kind of tired when I made the jsfiddle. What this was really about was that this code will trigger the error: \ \ {{{ \ $('<div></div>').dialog({ \ buttons: [ \ { \ text: 'Click for an error!' \ } \ ] \ }); \ }}} \ \ Because there is no default click event registered. \ \ I guess if I $.noop the click properly I can avoid an error but why define a click event if I do not need it. \ (In my case i'm just gonna pass the button to an extern library that will bind an event on it) \ \ \ 1417700123256217

Replying to [comment:1 scott.gonzalez]:

That's because you're passing undefined as the click property (you're executing the noop).

Sorry! My bad....

I was kind of tired when I made the jsfiddle. What this was really about is that this code will trigger the error:

    $('<div></div>').dialog({
        buttons: [
            {
                text: 'Click for an error!'
            }
        ]
    });

Because there is no default click event registered.

I guess if I $.noop the click properly I can avoid an error but why define a click event if I do not need it.

(In my case i'm just gonna pass the button to an extern library that will bind an event on it)

Changed December 04, 2014 01:43PM UTC by scottgonzalez comment:3

There is no reason to have a button that does nothing, therefore click is required.

Changed December 04, 2014 02:01PM UTC by DaazKu comment:4

Replying to [comment:3 scott.gonzalez]:

There is no reason to have a button that does nothing, therefore click is required.

You are right that a button that does nothing would be stupid.

But in some edge case there is no choice but to assign "nothing" for the click event in the dialog definition:

uploadDialog.instance = $(uploadDialogHTMLTemplate()).dialog({
    autoOpen: false,
    title: '[UPLOAD]',
    modal: true,
    draggable: false,
    resizable: false,
    width: 500,
    height: 300,
    buttons: [
        {
            class: 'browse',
            text: '[Browse Files]',
            click: $.noop
        }
    ]
});

resumable.assignBrowse($('button.browse', uploadDialog.instance.data()['ui-dialog']['uiButtonSet'])[0]);

But I understand that it's not common.

I just reread the DOC about the buttons property of dialog and it's made clear that you must provide the event handler so...

Thanks and have a good day!