开发者

Not able to toggle on Firefox

开发者 https://www.devze.com 2023-03-10 15:54 出处:网络
<div> <% var index = 0; foreach (var item in Model) { %> <div class=\"row <%= item.IsEditable ? \"\" : \"readonly\"%>
    <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;">&nbsp;</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;">&nbsp;</span>
    </div>
    <%
        index++;
        } %>
</div>

Your toggleMe function should be changed to take the element instead of its id.

0

精彩评论

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

关注公众号