0
jQuery 객체 자체에서 jQuery 플러그인을 호출하는 데 문제가 있습니다. 따라서 $(selector).myPlugin()
번으로 전화하는 대신 $.myPlugin
번으로 전화를 걸고 싶습니다. 어떤 이유로 그것이 함수가 정의되지 않았 음을 알려줍니다.jQuery 객체 자체에서 사용자 정의 jQuery 플러그인 호출하기
(function ($) {
var _current = null;
var methods = {
init: function (options) {
_current = $('.rfgQuestionsWrapper').filter(function() {
return $(this).css('display') != 'none';
}).first();
console.log(_current);
$('.gaugeTitle').click(function (e) {
var rfgCode = $(this).parent().find('.gaugeWrapper').attr('id');
console.log(rfgCode);
showByCode(rfgCode);
return false;
});
},
showByCode: function (rfgCode) {
var target = $.utilities.filterById('.rfgQuestionsWrapper', rfgCode);
console.log(target);
_current.hide();
target.show();
}
};
$.fn.navigationManager = function (method) {
if (methods[method]) {
return methods[method].apply(this, Array.prototype.slice.call(arguments, 1));
} else if (typeof method === 'object' || !method) {
return methods.init.apply(this, arguments);
} else {
$.error('Method ' + method + ' does not exist on jQuery.tooltip');
}
};
})(jQuery);
이 내가 전화를 처음으로이 방법 플러그인이기 때문에 내가 뭔가 잘못하고 있어야합니다
... 어떤 제안 :
여기 내 코드입니까?
이제는 상황이 훨씬 더 명확 해집니다 ... – Kassem
한 가지 더 질문이 있습니다 ... 'show' 메서드에서'showByCode' 메서드를 호출하는 것이 좋습니다. – Kassem
@Kassem methods.showByCode()가 작동해야합니다. – Andy