jquery-boilerplate-v3.1を使用してプラグインを開発しようとしていますが、「this」と「$(this)」が混同しています。
in the plugin
...
$.fn[pluginName] = function ( options ) {
//alert($(this).toSource());
return this.each(function () {
if (!$.data(this, 'plugin_' + pluginName)) {
$.data(this, 'plugin_' + pluginName, new Plugin( this, options ));
}
});
};
new Plugin(this, options)
Plugin.prototypeコンテキスト内の要素を返さないようです。
代わりに、に変更しましたPlugin($(this), options)
。
eg.
$(function(){
$('#container').myPlugin();
});
$(this)をパラメーターとして使用しないと、プラグインのthis.elementにアクセスできず、.toSource()は空のオブジェクトを返します({})
。
$(this)に変更して正しい方法を実行していますか、またはパラメーターを使用して#containerにアクセスするにはどうすればよいですかthis
。
TIA。