#10714 closed bug (notabug)
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
Change History (4)
comment:1 follow-up: 2 Changed 9 years ago by
Resolution: | → notabug |
---|---|
Status: | new → closed |
comment:2 Changed 9 years ago by
Replying to scott.gonzalez:
That's because you're passing
undefined
as theclick
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)
comment:3 follow-up: 4 Changed 9 years ago by
There is no reason to have a button that does nothing, therefore click
is required.
comment:4 Changed 9 years ago by
Replying to 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!
That's because you're passing
undefined
as theclick
property (you're executing the noop).