javascript - How to work with checkboxes generated from ezMark? -
i'm using ezmark library in website alongwith php, smarty, jquery, etc. here on 1 of webpages want disable few checkboxes depending on condition. after there 1 parent check box, upon selection of checkboxes not disabled should checked , should work vice-versa on deselcting parent check box. after checking parent checkbox if uncheck 1 of selected checkboxes(which not disabled) parent checkbox should unchecked. tried alot achieve regular code of checking , uncheking checkboxes (.attr('checked','checked')
, .removeattr('checked');
respectively) doesn't work in situation due ezmark library. i'm using following code check , uncheck checkboxes follows: code parent check box:
<p id="parentcheckbox" class="custom-form"> <input class="custom-check" type="checkbox" name="" id="ckbcheckall"> <a class="drop" href="#">more</a> </p>
the smarty code multiple checkboxes creation:
{section name=tests loop=$all_tests} <p class="custom-form"> <input class="custom-check checkboxclass" type="checkbox" name="" id="" {if $all_tests[tests].is_test_lock!=1 && $all_tests[tests].test_assign_to_package=='no'} {else} disabled {/if}> <label>{$all_tests[tests].test_name}</label> </p> {/section}
the jquery code selecting , deselectiong checkboxes upon parent checkbox:
$(document).ready(function() { $("#ckbcheckall").click(function () { if ($(this).is(':not(:checked)')) $(".ez-checkbox").removeclass("ez-checked"); if($(this).is(':checked')) $(".ez-checkbox").addclass("ez-checked"); }); });
when firbug element inspector i'm getting different html created child checkboxes follows:
<p class="custom-form"> <div class="ez-checkbox ez-checked"> <input id="" class="custom-check checkboxclass ez-hide" type="checkbox" name=""></input></div> <label>n1p: gravitation</label> </p>
i'm not getting <div>
tag coming. in order check , uncheck child checkboxes on selection of paren checkbox i'd written above logic. normal logic not getting worked due div
tag , ezmark library. current code child checkboxes getting selected including disabled ones upon selecting parent checkbox , upon unchecking parent checkbox child checkboxes unselected. can showing how achieve required functionality of selection , deselection of child checkboxes in scenario? in advance.
the jquery.ezmark generated structure not problem achieve want to. wrote this jsfiddle show way proceed based on css classes identify parent (.l0
) , children (.l1
).
i manually disabled checkboxes sample, can use condition disabled them.
hope can ;)
Comments
Post a Comment