var pageController = {
init: function () {
this.featureBtnInit(); // Function button initialization
},
featureBtnInit: function () { //Function button
var $featureBtn = $("#featureBtn");
var openClass = "btn-feature-open";
if (!$featureBtn[0])return this;
$featureBtn.on ( "click", function () {
if(!$featureBtn.hasClass(openClass)){
$featureBtn.addClass(openClass);
}else{
$featureBtn.removeClass(openClass) ;
}
}); [0]) {
$featureBtn.removeClass(openClass); ===== ============= Page starts ================== */
$(function () {
pageController.init ();
})
Question:
Are "init" and "featureBtnInit" defined attributes or methods? ? ? Why do we need to define 2 methods? You can just define a Function function. What are the benefits of defining it this way? ? ?
Reply to discussion (solution)
http://www.cnblogs.com/kuikui/archive/2013/07/14/ 3190381.html
1. Attributes. But properties are methods.
2. This defines the structure clearly. Methods can be called differently.
Not two methods, just methods that can call attributes. . .