https://learn.jquery.com/jquery-ui/widget-factory/extending-widgets/

https://api.jqueryui.com/jquery.widget/#method-_super

https://johnresig.com/blog/simple-javascript-inheritance/

To make the parent's methods available, the widget factory provides two methods - _super() and _superApply().

Using _super() and _superApply() to Access Parents

https://learn.jquery.com/jquery-ui/widget-factory/extending-widgets/#using-_super-and-_superapply-to-access-parents

_super() and _superApply() invoke methods of the same name in the parent widget. Refer to the following example. Like the previous one, this example also overrides the open() method to log "open". However, this time _super() is run to invoke dialog's open() and open the dialog.

$.widget( "custom.superDialog", $.ui.dialog, {
open: function() {
console.log( "open" ); // Invoke the parent widget's open().
return this._super();
}
}); $( "<div>" ).superDialog();
proxiedPrototype[ prop ] = (function() {
var _super = function() {
return base.prototype[ prop ].apply( this, arguments );
},
_superApply = function( args ) {
return base.prototype[ prop ].apply( this, args );
};
return function() {
var __super = this._super,
__superApply = this._superApply,
returnValue; this._super = _super;
this._superApply = _superApply; returnValue = value.apply( this, arguments ); this._super = __super;
this._superApply = __superApply; return returnValue;
};
})();

jquery ui widget 源码分析

 //在传入的ui原型中有方法调用this._super 和this.__superApply会调用到base上(最基类上)的方法
127 $.each(prototype, function(prop, value) {
128 //如果val不是function 则直接给对象赋值字符串
129 if (!$.isFunction(value)) {
130 proxiedPrototype[prop] = value;
131 return;
132 }
133 //如果val是function
134 proxiedPrototype[prop] = (function() {
135 //两种调用父类函数的方法
136 var _super = function() {
137 //将当期实例调用父类的方法
138 return base.prototype[prop].apply(this, arguments);
139 },
140 _superApply = function(args) {
141 return base.prototype[prop].apply(this, args);
142 };
143 return function() {
144 var __super = this._super,
145 __superApply = this._superApply,
146 returnValue;
147 // console.log(prop, value,this,this._super,'===')
148 // debugger;
149 //在这里调用父类的函数
150 this._super = _super;
151 this._superApply = _superApply;
152
153 returnValue = value.apply(this, arguments);
154
155 this._super = __super;
156 this._superApply = __superApply;
157 // console.log(this,value,returnValue,prop,'===')
158 return returnValue;
159 };
160 })();
161 });

this._super()的更多相关文章

  1. Java修炼——继承_super父类对象的引用

    Super是指直接父类对象的引用,可以通过super来访问父类中被子类覆盖的方法和属性. 当你调用子类的构造方法时,系统会默认给你先调用父类的构造方法,然后才会调用子类的构造方法. package c ...

  2. HTML5 学习总结(四)——canvas绘图、WebGL、SVG

    一.Canvas canvas是HTML5中新增一个HTML5标签与操作canvas的javascript API,它可以实现在网页中完成动态的2D与3D图像技术.<canvas> 标记和 ...

  3. TypeScript之面向对象初体验

    1.安装nodejs和vscode: nodejs : https://nodejs.org/en/ Visual Studio Code :  https://www.visualstudio.co ...

  4. 基于Nuclear的Web组件-Todo的十一种写法

    刀耕火种 刀耕火种是新石器时代残留的农业经营方式.又称迁移农业,为原始生荒耕作制. var TodoApp = Nuclear.create({ add: function (evt) { evt.p ...

  5. AlloyRenderingEngine燃烧的进度条

    写在前面 Github: https://github.com/AlloyTeam/AlloyGameEngine HTML 5新增了progress标签,那么再去使用AlloyRenderingEn ...

  6. AlloyRenderingEngine文本框组件

    写在前面 Github: https://github.com/AlloyTeam/AlloyGameEngine 在dom元素里,自带了input标签,设置其type为text,它就是一个文本框. ...

  7. 强大的observejs

    写在前面 各大MVVM框架的双向绑定太难以观察,很难直观地从业务代码里知道发生了什么,我不是双向绑定的反对者,只是认为双向绑定不应该糅合进底层框架,而应该出现在业务代码中,或者是业务和框架之间的代码上 ...

  8. AlloyRenderingEngine继承

    写在前面 不读文章,只对代码感兴趣可以直接跳转到这里 https://github.com/AlloyTeam/AlloyGameEngine然后star一下,多谢支持:). 前几天发了篇向ES6靠齐 ...

  9. 移动开发框架剖析(二) Hammer专业的手势控制

    浏览器底层并没有给元素提供类似,单击,双击,滑动,拖动这些直接可以用的控制接口,一切的手势动作都只能通过模拟出来.移动端浏览器唯一给我们提供的就只是mousedown -> mousemove ...

随机推荐

  1. [BZOJ 3625] [Codeforces 438E] 小朋友的二叉树 (DP+生成函数+多项式开根+多项式求逆)

    [BZOJ 3625] [Codeforces 438E] 小朋友的二叉树 (DP+生成函数+多项式开根+多项式求逆) 题面 一棵二叉树的所有点的点权都是给定的集合中的一个数. 让你求出1到m中所有权 ...

  2. 数塔 Easy

    在讲述DP算法的时候,一个经典的例子就是数塔问题,它是这样描述的: 有如下所示的数塔,要求从顶层走到底层,若每一步只能走到相邻的结点,则经过的结点的数字之和最大是多少?  已经告诉你了,这是个DP的题 ...

  3. kNN分类算法实现

    kNN算法就是计算每个点到其他所有点的距离,选出距离最小的k个点.在这k个点里,哪个类别的最多,就把待分类的点归到哪类. kNN.py: from numpy import * import oper ...

  4. scala学习笔记(8)

    1.trait ------------------------------- 如果只有一个trait就使用extends进行扩展,如果是多个,就使用with对生于trait进行扩展 trait lo ...

  5. Qradar SIEM--查询利器 AQL

    对于 SIEM 平台来说,好用的查询方式非常重要.之前有体验基于 ELK 搭建的平台,在 kibana 上面是可以通过一些 filter 来做一些过滤并且是支持 lucene 的语法,包括一些简单的逻 ...

  6. Response笔记

    # 今日内容          1. HTTP协议:响应消息     2. Response对象     3. ServletContext对象 ## HTTP协议:     1. 请求消息:客户端发 ...

  7. 【React 7/100 】 虚拟DOM和Diff算法

    虚拟DOM和Diff算法 React更新视图的思想是:只要state变化就重新渲染视图 特点:思路非常清晰 问题:组件中只有一个DOM元素需要更新时,也得把整个组件的内容重新渲染吗? 不是这样的 理想 ...

  8. Python multiprocessing使用详解

    multiprocessing包是Python中的多进程管理包. 与threading.Thread类似,它可以利用multiprocessing.Process对象来创建一个进程. 该进程可以运行在 ...

  9. Centos安装PHP PS:LAMP环境时,为少出错误,先安装一下编译环境

    下面安装PHP时数显很多问题,为了减少问题,直接安装先yum一下 yum -y install gcc pcre pcre-devel gcc-c++ autoconf libxml2 libxml2 ...

  10. Consider defining a bean of type 'org.springframework.web.client.RestTemplate' in your configuration

    https://www.cnblogs.com/EasonJim/p/7546136.html 错误如下: ERROR 31473 --- [ main] o.s.b.d.LoggingFailure ...