You shouldn't use any global variables like
window.__dialogWindowScrollHandled.  If you need to track properties
across multiple plugin instances you should use $.ui.dialog instead of
the window.


On Jun 27, 8:37 pm, Marv <[email protected]> wrote:
> Here's what I came up with after reading Scott G's post above (thanks
> Scott!!!). Anybody have comments on this as the "preferred method" to
> extend a widget?
>
> ====================================================================
>
> // This code block extends the uiDialog widget by adding a new boolean
> option 'sticky' which,
> // by default, is set to false. When set to true on a dialog instance,
> it will keep the dialog's
> // position 'anchored' regardless of window scrolling.
>
> // Start of uiDialog widget extension...
> var _init = $.ui.dialog.prototype._init;
> $.ui.dialog.prototype._init = function() {
>     var self = this;
>     _init.apply(this, arguments);
>     this.uiDialog.bind('dragstop', function(event, ui) {
>         if (self.options.sticky) {
>             var left = Math.floor(ui.position.left) - $
> (window).scrollLeft();
>             var top = Math.floor(ui.position.top) - $(window).scrollTop
> ();
>             self.options.position = [left, top];
>         };
>     });
>     if (window.__dialogWindowScrollHandled === undefined) {
>         window.__dialogWindowScrollHandled = true;
>         $(window).scroll(function(e) {
>             $('.ui-dialog-content').each(function() {
>                 var isSticky = $(this).dialog('option', 'sticky') && $
> (this).dialog('isOpen');
>                 if (isSticky) {
>                     var position = $(this).dialog('option',
> 'position');
>                     $(this).dialog('option', 'position', position);
>                 };
>             });
>         });
>     };};
>
> $.ui.dialog.defaults.sticky = false;
> // End of uiDialog widget extension...
>
> ===================================================================
>
> On Jun 25, 1:14 pm, Charlie <[email protected]> wrote:
>
> > just curious, when you extend like this do you append the extension to 
> > ui.tabs.js or place it with document.ready functions?
> > jvitela wrote:I do something like this whenever I want to extend a widget, 
> > what do you think? (function($) { /** * Extend Tabs to add strip spacer **/ 
> > $.fn.extend($.ui.tabs.prototype,{ _original_init : 
> > $.ui.tabs.prototype._init, _init: function() { this._original_init(); 
> > this.element.children('.ui-tabs-nav').after ('<div 
> > class="ui-tabs-strip-spacer"></div>'); } }); })(jQuery);
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"jQuery UI" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/jquery-ui?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to