On 3月3日, 下午11時56分, David Stamm <[EMAIL PROTECTED]> wrote:
> The function sayHello() is defined inside the function jQuery.example,
> and is thus an "inner function" or "nested function".  It exists only
> when jQuery.example is executing.  It cannot be accessed from outside
> jQuery.example without doing some magic with closures.
>
> When you tried to override sayHello by setting
> jQuery.example.sayHello, you created a new property "sayHello" on the
> jQuery.example object.  You can use this same technique to define this
> inner function the first time:
>
>         jQuery.example = function(name) {
>                 jQuery.example.sayHello(name);
>         };
>         jQuery.example.sayHello = function(str) {
>                 console.log("jQuery.example.sayHello: " + str);
>         };
>
> You can then override sayHello with the exact code you used above:
>
>         jQuery.example.sayHello = function(str) {
>                 alert("jQuery.example.sayHello(Overrided): " + str);
>         };
>
> This is probably the easiest solution.  Let me know if this doesn't
> answer your question.
>
> David
>

Thanks.

Unfortunately I don't want to modify the original sources, since for
example, sometimes you want to modify an existing plugin, you want to
make it more easy to maintain by function overriding. (Consider if
they roll up a new version)

Anyway, seems no better way.

thanks.

Reply via email to