이벤트에 관한 약간의 문제가 있습니다. 그래서 나는 다른 플러그인이라고 불리는 플러그인 허풍을 가지고 있고, jquery 엘리먼트를 메인 플러그인으로 불리는 플러그인으로부터 얻고 싶다. 패널 : 정의되지 않은 onchange를 :jquery vars 이벤트에
(function($) {
$.fn.meRadioCheck = function(options, callback) {
options = $.extend($.fn.meRadioCheck.defaults, options);
var plugin = this;
plugin.init = function() {
return this.each(function() {
var $this = $(this);
var $span = $('<span/>');
var name = $this.attr('name');
/* here some stuff... */
/* check for Events */
if (($._data(this, "events") == null)) {
/* Change Event an Element binden */
$this.bind("xonChange", function() {
options.CheckBox_onChange.call($this)
});
$this.on({
change: function() {
/* here some stuff... */
/* throw Change Event */
$this.trigger("xonChange");
},
});
};
});
}
return this.each(function() {
var $this = $(this);
var name = $this.attr('name');
if (options.checked != $this.prop('checked')) { $this.click(); }
if (options.disabled) { $this.prop('disabled', true) } else { $this.prop('disabled', false) }
});
};
// Standard-Optionen für das Plugin
$.fn.meRadioCheck.defaults = {
'checked': false, /* This Checkbox or Radio Button is checked */
'debug': false, /* Debug Modus für das Plugin ein od. ausschalten */
'disabled': false, /* This Checkbox or Radio Button is disabled */
'CheckBox_onChange': function(el) {},
'RadioButton_onChange': function(el) {}
}
})(jQuery);
(function($) {
$.panel = function(options, callback) {
$('input[type=checkbox], input[type=radio]').meRadioCheck({
CheckBox_onChange: function(el) {
/* some stuff here... */
window.console.debug('panel: ' + typeof(el) + ', onChange: ', [el])
}
});
}
})(jQuery);
난 단지 콘솔이 얻을 [정의]
을하지만 난 체크 박스 또는의 RadioButton을 싶어. 누군가가 나를 도울 수 있기를 바랍니다 ...
감사 ... 좋은 주말 보내세요.
은'init()'라고 불리우나요? – Tomalak
아니요, 처음에는'init()'을 단지 한 번만 호출합니다.'$ ('input [type = checkbox], input [type = radio]') meRadioCheck(). init();' – Tabes
이는 jQuery 플러그인이 일반적으로 설계된 방식에 대한 것이므로 재검토해야한다. – Tomalak