Not able to toggle on Firefox
<div>
<%
var index = 0;
foreach (var item in Model)
{ %>
<div class="row <%= item.IsEditable ? "" : "readonly"%>
<%= index % 2 == 0 ? "row":"rowAlt" %>
var cId = <%= item.Id %>
<%= item开发者_开发知识库.IsEditable ? "onclick='page.toggleMe(cId)'":"" %>
<span style="float: right;"> </span>
</div>
<%
index++;
} %>
</div>
The code above works on IE and toggles the row by passing cId. However, the same code doesn't work in Firefox. I think it is not able to recognize the way cId is being passed. I also tried:
<%= item.IsEditable ? "onclick='page.toggleMe(<%= item.Id %>)'":"" %>
but shows a syntax error. Any workarounds to get this working on FF?
I'll attempt to post a fix for this, but there are quite a few mistakes in the code you posted; likewise, the way you are going about this is very awkward to say the least. Furthermore, I am unclear as to what your goal is.
<div>
<%
var index = 0;
foreach (var item in Model)
{ %>
<div class="row <%= item.IsEditable ? "" : "readonly"%>
<%= index % 2 == 0 ? "row":"rowAlt" %>"
id="<%= item.Id %>"
<%= item.IsEditable ? "onclick='page.toggleMe(this)'":"" %> >
<span style="float: right;"> </span>
</div>
<%
index++;
} %>
</div>
Your toggleMe function should be changed to take the element instead of its id.
精彩评论