开发者

jquery tmpl default options

I have a series of helper开发者_开发知识库 functions to do formatting, etc inside jQuery.tmpl templates. The documentation suggests this can be passed in as the options argument in the template function. What I'd like is to have all these helper functions included by default into any jquery template, so I don't have to explicitly add it every time.

I realize this could be done with a global variable, but I kind of like the $item.xxx()syntax... Is there a way to specify default options for templating, similar to $.ajaxOptions or any of the other defaulting mechanisms, or is this a bad idea to begin with?


The jQuery templating plugin docs are here. I don't see anything there about global options though.

You could, perhaps:

  • move your code into your own plugin to make it easier to access/more generic
  • Or edit the templating plugin's code yourself - though this may be more complicated since you'll have to understand what the code is doing and know what to modify
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜