1
私は最初のjqueryプラグインを作成しています。私は基本的なコーディングを行いましたが、コードを内部でリファクタリングし、関数内にいくつかのセクションを配置したいと考えています。プラグインの外からこれらの関数を呼びたくないことに注意してください。私的な機能だと思います。これは、やや私が入れたいの論理である -宣言と混同jqueryプラグインの中から呼び出される関数を使用
(function($) {
$.fn.filterGroup = function(method)
{
var someParam,someOtherParam; //declared here and values updated inside someFunction(), anotherFunction()
return this.each(function()
{
//plugin code starts here
this.someFunction();
alert(someParam); //I want updated value of someParam to be available here
$(inputTextField).keyup(function()
{//as user enters input into an input field
inputText = $(inputTextField).val();
//call a function here on this and does some modification on it.
this.anotherFunction(); //move a lot of lines inside this function
//on subsequent keyups, I want the updated value of someOtherParam to be available here
alert(someOtherParam);
}
});
//not sure where and how to declare these functions ... these needs to be called from inside the plugin only (private functions)
someFunction = function(filterText)
{
//some logic on the passed this, not sure if my sentence is correct in terms of jquery...
//var someParam is updated here
someParam = "something";
}
anotherFunction = function(filterText)
{
//var someOtherParam is updated here
someOtherParam = "something";
}
});
})(jQuery);
私の質問がある -
- どこでどのように私は
this.someFunction();
のようにそれを呼び出すことができるように、私は、someFunction()
を定義します。 - そして、その後の
onkeyup()
イベント中に更新された値someParam
を読み取ることができるようにする必要があります。
私はhttp://docs.jquery.com/Plugins/Authoringの名前空間セクションをチェックするが、それは外から呼び出されるパブリック関数についてですように見えます。
はまた、これらの質問を確認 -
Using functions from inside a pluginおよび他のいくつかが、私は混乱しています。ここで