0

前回の質問で答えが得られなかったので、このプラグイン構造を使用することにしました。

(function ( $ ) {

$.fn.myPlugin = function (options) {
options = $.extend( {}, $.fn.myPlugin.defaults, options );
    return this.each(function (i, el) {
     ("someiD").live("click",function() {
            UpdateCounter();
        });

    });
};

$.fn.myPlugin.defaults = {
///options here for overiding
};
}(jQuery));

カウンターを増やすためにボタンを選択する必要があるプラグインを作成しましたが、ボタンの OnSelect/OnClick であるカウンターの更新された値を取得する方法がわかりません....誰か教えてもらえますかプラグインの構造を変更せずにこれをどのように処理すればよいかについての洞察はありますか?

4

1 に答える 1

1

基本的にこのように:

(function ( $ ) {
  $.fn.myPlugin = function (options) {
    options = $.extend( {}, $.fn.myPlugin.defaults, options );

    // $(this) is your selected element, #someSelect in this case
    $(this).on('select', function(e) {
      console.log('selected!')
    })

};

// execute your plugin on the selected element
$('#someSelect').myPlugin();
于 2012-11-21T13:13:37.180 に答える