Opened 6 years ago

Closed 6 years ago

Last modified 6 years ago

#8862 closed bug (worksforme)

Widget automatic element generation does not see overrided widgets

Reported by: ghen Owned by:
Priority: minor Milestone: 1.10.0
Component: ui.widget Version: 1.9.2
Keywords: Cc:
Blocked by: Blocking:


If there is overrided version of some widget (for example, dialog) and we call direct instatination, then it does not see overrided version

Or script itself:

$.widget('sample.dialog', $.ui.dialog, {
    _create: function() {
        this.options.title = 'Overrided title';

$('#dlgOld').click(function(e) { alert('old');
    $('<div></div>').appnedTo($('body')).dialog({ title: 'Some title' });
    e.preventDefault(); return false;
$('#dlgNew').click(function(e) { alert('new');
    $.ui.dialog({ title: 'Some title' });
    e.preventDefault(); return false;

Change History (4)

comment:1 Changed 6 years ago by Scott González

Resolution: worksforme
Status: newclosed

There were about a dozen errors that I needed to fix in that fiddle just to get it to run. Ignoring the fact that you have old and new reversed, I've fixed all of your other problems and it's working fine:

comment:2 Changed 6 years ago by ghen

Sorry, but I think you just didn't get it.

When you use Old API approach, it overrides dialog title, because it calls it through the extended widget. So the final title is 'Overrided title'.

When you call it through direct injection, the title is 'Some title', because it goes through original dialog widget.

PS: as of errors, there were no any errors and jQuery references were added through the resources on the left pane. But anyway, even your current version reproduces the error I've described. I just tried to help you with QA.

comment:3 Changed 6 years ago by Scott González

I don't know what error you're trying to describe. The behavior you describe is the expected behavior. Did you mean to call $.sample.dialog instead of $.ui.dialog?

Also, I'm not sure how you can say there were no errors in your fiddle.

  • The resources were not added in the side panel.
  • The call to $.widget() is missing the closing paren.
  • The ids you were binding click event handlers to don't even exist.
  • .appendTo() is spelled incorrectly.

comment:4 Changed 6 years ago by ghen

Now I see the point. If we use 'sample' namespace, then it works as expected. It was a little surprising for me. I thought overriding will work globally, as it works when we just call '.dialog(...)' on 'div' element. Java Script prototypes basics :).

PS: as of errors, from your description it looks like very early version of test with alerts for debug. I think, I just didn't save the lat version (Ctrl+S). D'Ouh...

Thank you for explanation and for your time!

Note: See TracTickets for help on using tickets.