Re: [jQuery] addclass and json
I used class as an example to show what each variable was. Test code is like this This function is used to process $.getJSON data process(data) { args = data[i].a // data is an array of commands, a = green $('#text').addClass(args); // does not work $('#text').addClass(args.toString()); // does work } This only started when I upgraded to 1.1.1 it did not happen in earlier versions. The problem is this is used in a more dynamic script, In this case args is a single string but in other cases it might not be, If I have to call toString() each time I have to make a new process for every diffrent method combination. Example of what I am trying to do $(element)[data[i].m](args); I did a catch on the error and I am getting a "TypeError c.split is not a function" On 2/26/07, Erik Beeson <[EMAIL PROTECTED]> wrote: > > addClass(json.class) addClass and jquery die with no visible error in > > firebug > > I've found proper exception handling can help track down "no visible > error" type bugs: > > try { > // code here > } catch(e) { > alert("There was a problem with that code: " + e); > } > > But like Karl said, using "class" is probably the problem. Good luck with it. > > --Erik > > ___ > jQuery mailing list > discuss@jquery.com > http://jquery.com/discuss/ > ___ jQuery mailing list discuss@jquery.com http://jquery.com/discuss/
Re: [jQuery] addclass and json
> addClass(json.class) addClass and jquery die with no visible error in firebug I've found proper exception handling can help track down "no visible error" type bugs: try { // code here } catch(e) { alert("There was a problem with that code: " + e); } But like Karl said, using "class" is probably the problem. Good luck with it. --Erik ___ jQuery mailing list discuss@jquery.com http://jquery.com/discuss/
Re: [jQuery] addclass and json
Sidenote: If you do need to use "class" as an attribute / property name you could access it via: json['class'] Karl Rudd On 2/27/07, Richard Thomas <[EMAIL PROTECTED]> wrote: > I am trying to pass a value to addClass, If I hardcode 'green' it works > if I do var = green > addClass(var) > > It works > > If I try to use a value from jquery json data like > addClass(json.class) addClass and jquery die with no visible error in > firebug > > If I do > > json.class.toString() it works, Prior to version 1.1.1 I never had to > specify toString > > Any ideas? > > ___ > jQuery mailing list > discuss@jquery.com > http://jquery.com/discuss/ > ___ jQuery mailing list discuss@jquery.com http://jquery.com/discuss/
Re: [jQuery] addclass and json
In JavaScript "class" is a reserved word. Perhaps that's the problem? If not then it'd be best to post a URL to an example page so we can have a look at it. Karl Rudd On 2/27/07, Richard Thomas <[EMAIL PROTECTED]> wrote: > I am trying to pass a value to addClass, If I hardcode 'green' it works > if I do var = green > addClass(var) > > It works > > If I try to use a value from jquery json data like > addClass(json.class) addClass and jquery die with no visible error in > firebug > > If I do > > json.class.toString() it works, Prior to version 1.1.1 I never had to > specify toString > > Any ideas? > > ___ > jQuery mailing list > discuss@jquery.com > http://jquery.com/discuss/ > ___ jQuery mailing list discuss@jquery.com http://jquery.com/discuss/
[jQuery] addclass and json
I am trying to pass a value to addClass, If I hardcode 'green' it works if I do var = green addClass(var) It works If I try to use a value from jquery json data like addClass(json.class) addClass and jquery die with no visible error in firebug If I do json.class.toString() it works, Prior to version 1.1.1 I never had to specify toString Any ideas? ___ jQuery mailing list discuss@jquery.com http://jquery.com/discuss/