来自java,如果需要,一个类将在其单独的文件中,看起来像这样。
AClass.java
class AClass{
public AClass{
}
}
在另一个文件中,您将创建一个实例
AClass classInstance = new AClass();
如何使用Jquery UI获得相同的功能? 我想要我的index.html
<html>
<div class='be_a_plugin'></div>
<button class='a_class'></button>
<script src='init.js'></script>
<script src='implement.js'></script>
</html>
我的init.js文件
//Not sure what should go here.
//How do i do this? Lets see ummm
extend $.widget("ns.plugin");?
extend $.anotherwidget;?
//I just want all my widgets(which i intend to create each in a separate file) to be available to my implement.js and still be organized
我的一个班级
$.widget( "ns.plugin", {
// Default options.
options: {
param1: "foo",
param2: "bar",
param3: "baz"
},
_create: function() {
// Options are already merged and stored in this.options
// Plugin logic goes here.
}
});
我的implement.js
$('.a_class').on("click",function(){
$('.be_a_plugin').plugin();
});