jqueryプラグインインスタンス(私が作成したもの)間でプロパティとメソッドを共有したいのですが、それを適切に行うにはどうすればよいですか?
次のように定義された単純なプラグインがあるとします。
// add the plugin to the jQuery.fn object
$.fn.clickableImage = function(options) {
this.set_not_clicked = function(){
return this.each(function() {
$(this).addClass('not-clicked');
});
};
// iterate through the DOM elements we are attaching the plugin to
return this.each(function() {
$(this).click( function(){
parent.set_not_clicked() //how to get "parent" ???
$(this).removeClass('not-clicked').addClass('clicked');
});
});
}
そして、次のようにインスタンス化された画像:
$(function(){
$('#some-selector img').clickableImage();
});
「clickableImage」に他の「clickableImage」を認識させる方法は?