jQuery: The Write Less, Do More JavaScript Library

Issue when caching jquery objects

View: New views
3 Messages — Rating Filter:   Alert me  

Issue when caching jquery objects

by north-6 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi,

I usually cache jquery objects in variables or a config object.

Lately I ran into a strange issue with that when trying to do this:

$myCachedSelector.attr('disabled', false);

The selected object simply remained to be disabled.

When I used the normal syntax $('#mySelector').attr('disabled',
false); it worked.

I'm not sure if it's a problem with my script of some kind of "bug"?

Any ideas?

Thanks!

Re: Issue when caching jquery objects

by James-279 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Does:

    $myCachedSelector.removeAttr('disabled');

work as expected?

On Nov 1, 11:42 pm, north <ollo...@...> wrote:

> Hi,
>
> I usually cache jquery objects in variables or a config object.
>
> Lately I ran into a strange issue with that when trying to do this:
>
> $myCachedSelector.attr('disabled', false);
>
> The selected object simply remained to be disabled.
>
> When I used the normal syntax $('#mySelector').attr('disabled',
> false); it worked.
>
> I'm not sure if it's a problem with my script of some kind of "bug"?
>
> Any ideas?
>
> Thanks!

Re: Issue when caching jquery objects

by north-6 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi James,

this issue occured when I was using variables to store the objects.
Now I'm using a config object, and if I do something like this:

config.$myCachedSelector.attr('disabled', false);

it works...

Thanks

On 2 Nov., 20:15, James <james.gp....@...> wrote:

> Does:
>
>     $myCachedSelector.removeAttr('disabled');
>
> work as expected?
>
> On Nov 1, 11:42 pm, north <ollo...@...> wrote:
>
> > Hi,
>
> > I usually cache jquery objects in variables or a config object.
>
> > Lately I ran into a strange issue with that when trying to do this:
>
> > $myCachedSelector.attr('disabled', false);
>
> > The selected object simply remained to be disabled.
>
> > When I used the normal syntax $('#mySelector').attr('disabled',
> > false); it worked.
>
> > I'm not sure if it's a problem with my script of some kind of "bug"?
>
> > Any ideas?
>
> > Thanks!