I guess I could also create a global object, and then store all the
variables and functions in there. But in this case it's not so
important, because the widget will be the only content on the page and
loaded into an iframe.

On 21 Jul., 13:25, Jules <jwira...@gmail.com> wrote:
> I found out that jquery.validate code uses the form object to store
> global variables.  Taking clue from the code, I uses the document
> object $.data($(document)[0], 'myData', myData).  Not sure if this is
> the best practice, may be others can shed some light to the best
> practice to store global variables.
>
> On Jul 21, 8:51 pm, north <ollo...@web.de> wrote:
>
> > Hi,
>
> > I just created a little widget using jQuery. The code is kinda ugly,
> > but I'm trying to improve it at least a bit. The first thing I wanted
> > to do was to cache the jQuery objects. In this case I created global
> > variables for this.
>
> > Besides the global variables, I have a couple of functions using
> > "live" to bind a handler to an mousedown or click event.
>
> > Now, when trying to use the variables in those functions I recognized
> > two "effects":
>
> > 1.
> > Trying to apply .attr('disabled': true) to one of the cached objects
> > doesn't work, while applying other attributes seems to work fine.
>
> > 2.
> > When defining a new variable in one of the functions, and trying to
> > use one of the global ones in it, it also doesn't seem to work
> > (something like this: var seriesAjaxOptions = $seriesAjax.html(); -
> > $seriesAjax being a cached object).
>
> > Any idea what's going on (or what could be going on) here?
>
> > Thanks!
>
>

Reply via email to