I have menu list in div tag where onPageLoad I am taking menus,submenus and displaying it.
Now I am calling ajax call,when I click on user name it should check the checkebox which he has right to access the sub-menu.
The part which I have done is like comparision of ids & keys.I am stuck on check the checkbox dynamically if both condition meet.
HTML code looks like,
<div class="col-md-12 col-lg-12" id="showRights" style="display: none;">
<% for(var i=0;i< data.length;i++){
if(data[i].has_child == 1) {
%>
<div class="panel panel-primary">
<div class="panel-heading"><%= data[i].name %></div>
<% for(var j=0;j<data.length;j++){
if(data[j].id == data[i].id && data[j].has_child == 0){
%>
<div class="panel-body">
<div class="checkbox" id="rightCheck">
<label>
<input type="checkbox" class = "rightCheck" value="<%= data[j].menu_id %>" ><%= data[j].name %>
</label>
</div>
</div>
<% } }%>
</div>
</div>
I tried $(".rightCheck").prop("checked",true);
but this checks the all checkboxes. how to write condition for that ?
Aucun commentaire:
Enregistrer un commentaire