简体   繁体   English

jQuery模板

[英]JQuery templating

是否可以在JQuery模板中根据字段中的值指定特定图像(在这种情况下,它是一个布尔字段{MainYN},如果该值是true,我想显示一个刻度图像,如果该值是true,则我想显示一个十字图像值是否为假)?

unfortunatly JQuery template makes a simple replace of {Variable} with the values inserted in the ArrayValue passed to the template function. 不幸的是,JQuery模板使用插入到传递给模板函数的ArrayValue中的值简单地替换了{Variable}。 I've solved this problem passing the full path of the image to the template. 我已经解决了将图像的完整路径传递给模板的问题。

There are a couple of ways this can be accomplished but the general steps are the same. 有两种方法可以完成此操作,但一般步骤相同。

In your template, just add some if logic: 在模板中,只需添加一些if逻辑:

{{if MainYN === true}}
  <img src="tick.png" />
{{else}}
  <img src="cross.png" />
{{/if}}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM