Thursday, January 22, 2009

Trimpath error "context._MODIFIERS is undefined"

I was doing a little JavaScript templating with Trimpath today and at one point I was getting a nice error in my console of:

context._MODIFIERS is undefined

Looking through the trimpath code it turned out this was because I was passing in a string rather than an object as my context for the generation of the template. So I was effectively doing:

TrimPath.processDOMTemplate("someNodeId", "some string");

rather than:

TrimPath.processDOMTemplate("someNodeId", {key: "value", otherKey: "value"});

In my case I was getting the error because I forgot to eval some JSON before passing it to trimpath.


Noah Botimer said...

I ran into this the other day and, likewise, found a JSON string to be the cause. Mine happened because of using jQuery .get instead of .getJSON. I tried the type parameter, but I guess I screwed something up. Oh well; getJSON evaluates and gives you an object.

Cody Burleson said...

Thanks for posting this! Got me out of a jam.