Skip to main content

Search and Top Navigation

#8862 closed bug (worksforme)

Opened November 27, 2012 09:44PM UTC

Closed November 28, 2012 02:15AM UTC

Last modified November 28, 2012 03:17AM UTC

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:
Description

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

http://jsfiddle.net/SxVUj/

Or script itself:

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

$('#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;
});
Attachments (0)
Change History (4)

Changed November 28, 2012 02:15AM UTC by scottgonzalez comment:1

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: http://jsfiddle.net/SxVUj/1/

Changed November 28, 2012 02:28AM UTC by ghen comment:2

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.

Changed November 28, 2012 02:36AM UTC by scottgonzalez comment:3

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.

Changed November 28, 2012 03:17AM UTC by ghen comment:4

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!