Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
次のように初期化する単純なjQueryボタンウィジェット(プラグイン)を作成しました:
var cmd = $(".tButton"); cmd.tButton();
今後のすべてのボタンに .live を使用する方法はありますか (ajax 経由でロードされます)?
どうも
できますが、自分がしていることに注意してください。プラグイン接続コードを自動的に再実行したい場合は、それ$.fn.live()は望ましくありません。
$.fn.live()
いくつかのイベント ハンドラーをアタッチする場合は可能ですが、次のようにメイン コレクションにアタッチする必要があります。
$.fn.yourPlugin = function(){ this.live('click', function(){...}); }