Friday, June 26, 2009

[jQuery] Re: call a method outside a jquery object

On Jun 26, 12:44 pm, jakiri hutimora <jakirihutim...@gmail.com> wrote:
> Actually I really need to access to a method inside another function.
> $(
> function(){
> function openMenu(){
> doSomething(x);
> }
> function closeMenu(){
> doSomething(x);
> }
>
> }
> );

Why are you defining these functions inside $()? Just define them
outside of $() and they will be global.

function openMenu(){
doSomething(x);
}
function closeMenu(){
doSomething(x);
}
$(openMenu);

If you want a function to be available outside of the function scope
that is currently executing, then define it outside.

Matt Kruse

No comments: