<i id='c8SBV'><tr id='c8SBV'><dt id='c8SBV'><q id='c8SBV'><span id='c8SBV'><b id='c8SBV'><form id='c8SBV'><ins id='c8SBV'></ins><ul id='c8SBV'></ul><sub id='c8SBV'></sub></form><legend id='c8SBV'></legend><bdo id='c8SBV'><pre id='c8SBV'><center id='c8SBV'></center></pre></bdo></b><th id='c8SBV'></th></span></q></dt></tr></i><div id='c8SBV'><tfoot id='c8SBV'></tfoot><dl id='c8SBV'><fieldset id='c8SBV'></fieldset></dl></div>
    1. <small id='c8SBV'></small><noframes id='c8SBV'>

    2. <legend id='c8SBV'><style id='c8SBV'><dir id='c8SBV'><q id='c8SBV'></q></dir></style></legend>

        <bdo id='c8SBV'></bdo><ul id='c8SBV'></ul>
    3. <tfoot id='c8SBV'></tfoot>
    4. 使用重新定义父方法在 Jquery UI 中扩展小部件

      Extending widgets in Jquery UI with redefining parent methods(使用重新定义父方法在 Jquery UI 中扩展小部件)
          • <bdo id='OJnur'></bdo><ul id='OJnur'></ul>

            • <legend id='OJnur'><style id='OJnur'><dir id='OJnur'><q id='OJnur'></q></dir></style></legend>

              <small id='OJnur'></small><noframes id='OJnur'>

              <i id='OJnur'><tr id='OJnur'><dt id='OJnur'><q id='OJnur'><span id='OJnur'><b id='OJnur'><form id='OJnur'><ins id='OJnur'></ins><ul id='OJnur'></ul><sub id='OJnur'></sub></form><legend id='OJnur'></legend><bdo id='OJnur'><pre id='OJnur'><center id='OJnur'></center></pre></bdo></b><th id='OJnur'></th></span></q></dt></tr></i><div id='OJnur'><tfoot id='OJnur'></tfoot><dl id='OJnur'><fieldset id='OJnur'></fieldset></dl></div>
              <tfoot id='OJnur'></tfoot>
                <tbody id='OJnur'></tbody>

                本文介绍了使用重新定义父方法在 Jquery UI 中扩展小部件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                问题描述

                我尝试根据 documentation(UI 版本 1.8.16)扩展 UI 对话框:

                I try to extend UI dialog according to documentation (UI version 1.8.16):

                (function($) {
                    $.widget('ui.mydialog', $.extend(true, $.ui.dialog.prototype, {
                        _create: function() {
                            return $.Widget.prototype._create.apply(this, arguments);
                        }
                    }));
                })(jQuery);
                
                $(function() {
                    $('div#dialog').mydialog();
                });
                

                执行此代码会导致 JS 错误:this.uiDialog is undefined".

                Executing of this code causes JS error: "this.uiDialog is undefined".

                如果尝试重写 _init() 方法没有错误,但父方法调用无效.

                And if try to override the _init() method there are no errors, but parent method call takes no effect.

                我很困惑..哪种方式可以合法扩展例如放一些自定义初始化代码?

                I'm confused.. Which way is legal to extending for e.g. put some custom initialize code?

                推荐答案

                我认为这篇文章会解决你的问题:从 jQuery UI 对话框继承并调用被覆盖的方法.

                I think this post would solve your question: Inherit from jQuery UI dialog and call overridden method.

                简而言之,如果你想构建一个继承 jQuery UI Dialog 的小部件,你可以这样做:

                In short, if you want to build a widget inheriting jQuery UI Dialog, you can do this:

                (function($) {
                    $.widget("ui.mydialog", $.ui.dialog, {
                        _create: function() {
                            $.ui.dialog.prototype._create.call(this);
                        }
                    });
                
                })(jQuery);
                

                查看实际操作:http://jsfiddle.net/william/RELxP/.

                本教程将启发你:http://wiki.jqueryui.com/w/page/12138135/Widget%20factory.简而言之,$.Widget 是基础小部件对象.即使它有一个 _create 函数,默认情况下它什么也不做,将初始化代码留给子类.看看这个更新的例子:http://jsfiddle.net/william/RELxP/1.

                This tutorial will enlighten you: http://wiki.jqueryui.com/w/page/12138135/Widget%20factory. In short, $.Widget is the base widget object. Even though it has a _create function, it by default does nothing, leaving the initialisation code to the subclass. Take a look at this updated example: http://jsfiddle.net/william/RELxP/1.

                这篇关于使用重新定义父方法在 Jquery UI 中扩展小部件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                相关文档推荐

                Pause youtube video, youtube api(暂停 youtube 视频,youtube api)
                Youtube iframe api not triggering onYouTubeIframeAPIReady(Youtube iframe api 未触发 onYouTubeIframeAPIReady)
                How can I stop a video with Javascript in Youtube?(如何在 Youtube 中停止使用 Javascript 的视频?)
                How to call Greasemonkey#39;s GM_ functions from code that must run in the target page scope?(如何从必须在目标页面范围内运行的代码中调用 Greasemonkey 的 GM_ 函数?)
                How do you mute an embedded Youtube player?(如何使嵌入式 Youtube 播放器静音?)
                How to get number of video views with YouTube API?(如何使用 YouTube API 获取视频观看次数?)

                  <tbody id='cnp8V'></tbody>

                    <small id='cnp8V'></small><noframes id='cnp8V'>

                  1. <i id='cnp8V'><tr id='cnp8V'><dt id='cnp8V'><q id='cnp8V'><span id='cnp8V'><b id='cnp8V'><form id='cnp8V'><ins id='cnp8V'></ins><ul id='cnp8V'></ul><sub id='cnp8V'></sub></form><legend id='cnp8V'></legend><bdo id='cnp8V'><pre id='cnp8V'><center id='cnp8V'></center></pre></bdo></b><th id='cnp8V'></th></span></q></dt></tr></i><div id='cnp8V'><tfoot id='cnp8V'></tfoot><dl id='cnp8V'><fieldset id='cnp8V'></fieldset></dl></div>

                      <tfoot id='cnp8V'></tfoot>
                        <legend id='cnp8V'><style id='cnp8V'><dir id='cnp8V'><q id='cnp8V'></q></dir></style></legend>

                          <bdo id='cnp8V'></bdo><ul id='cnp8V'></ul>