Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
New feature for OptionTree: Show/hide options base on other option selection.
// Options toggler hanlder
// To turn on/off other options base on toggler selection
function initOptionToggler() {
$(document).delegate('.yk-toggler', 'click', function(){
var toggler_name = $(this).attr("name").replace("option_tree[","").replace("]","");
var toggler_value = $(".yk-toggler[name*="+toggler_name+"]:checked").val();
// Turn off all .yk-toggle-able fields
// Turn on fields that relate with toggler's value
setTimeout(function() {$(".yk-toggler:checked").click();}, 5);
Copy link

thanh4890 commented Apr 17, 2013

It works very well, thank so much!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment