如何将额外的变量和参数传递给jQote2?
我有几个 Javascript 函数,它们连接一个 URL,我将其设置为变量 c。然后,我尝试将该变量传递到 jQote2:
$.get("emptyReq.tpl", function(tmpl,c) {
$("#reqs").jqoteapp(tmpl, result, c);
});
在emptyReq.tmpl 中,我正在执行以下操作:
<tr id="row">
<td name="id" class="id"><a href="<%=this.c%>"><%= this.FormattedID %></a></td>
<td name="name" class="name"><%= this._refObjectName %></td>
<td name="state" class="state"><%= this.ScheduleState %></td>
<td name="owner" class="owner"></td>
</tr>
我尝试了几种变体(this.c 和 c),并且我也尝试了不同的变量,但我无法正确显示 URL。
c 在控制台中被标记为未定义,并且 URL 最终类似于: http://127.0.0.1/xampp/py2/undefined 而不是实际的 c ,类似于 https://rally1.rallydev.com/slm/rally.sp# /2735190513d/detail/userstory/4599269614
有办法通过吗参数正确吗?或者我应该在 .tmpl 文件本身中进行串联?
以下是我一直用作参考的内容:jQote 参考。
I have a couple Javascript functions which concatenates a URL which I set to the variable c. I then try to pass that variable into jQote2:
$.get("emptyReq.tpl", function(tmpl,c) {
$("#reqs").jqoteapp(tmpl, result, c);
});
In emptyReq.tmpl, I'm doing the following:
<tr id="row">
<td name="id" class="id"><a href="<%=this.c%>"><%= this.FormattedID %></a></td>
<td name="name" class="name"><%= this._refObjectName %></td>
<td name="state" class="state"><%= this.ScheduleState %></td>
<td name="owner" class="owner"></td>
</tr>
I've tried a couple of variations (this.c and c) and I've also tried different variables, but I'm not able to get the URL to display correctly.
c is labeled as undefined in the console, and the URL ends up being something like: http://127.0.0.1/xampp/py2/undefined instead of the actual c which is something like https://rally1.rallydev.com/slm/rally.sp#/2735190513d/detail/userstory/4599269614
Is there a way to pass the parameters properly? Or am I supposed to do the concatenation in the .tmpl file itself?
Here is what I've been using as a reference: jQote Reference.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
rishimaharaj,
jqoteapp
方法的第三个参数用于在每次调用的基础上更改模板标记(默认情况下<% ... %>
)。如果您需要将其他数据传递到模板,您有两个选择:c
设为全局变量(不过我不建议这样做)复制
c
'data
参数的 s 值(推荐):请注意,复制时需要考虑您的类型
模板化数据是,即单个对象的处理方式与数组不同
对象!
更改此设置后,您将能够通过模板访问
c
lamda 的固有属性
data
:问候,
埃夫克斯
rishimaharaj,
the
jqoteapp
method's third paramter is used to change the template tag (<% ... %>
by default) on a per call basis. If you need to pass additional data to your template you have two options:c
a global variable (I wouldn't recommend that, though)Copy
c
's value to thedata
parameter (recommended):Please be aware that the copying needs to take into account of what type your
templating data is, i.e. a single object is handled different from an array of
objects!
Once you've changed this, you will be able to access
c
through the templatinglamda's inherent property
data
:Regards,
aefxx