wordpress - Hide/show radio buttons stop working on save -
here's case: i'm developing little widget, , looking way hide/show different divs on selecting set of radio buttons. found proper code , adjusted needs. problem hide/show feature stops working after clicking on save while configuring widget :s
here's js:
jquery(document).ready(function($) { $(document).ready(function() { $('input[type="radio"]').click(function(){ if($(this).attr("value")=="link_to_image"){ $(".radio-option").hide(); $(".linked-image").show(); } if($(this).attr("value")=="link_to_page"){ $(".radio-option").hide(); $(".linked-page").show(); } }); }); }); and html:
<p> <label>link:</label><br> <label> <input type="radio" name="link_to" value="link_to_image"> link image </label><br> <label> <input type="radio" name="link_to" value="link_to_page"> link page </label> </p> <div class="linked-image radio-option"> <label for="linked_image">linked image:</label> <p> content linked_image div </p> </div> <div class="linked-page radio-option"> <label for="linked_page">linked page:</label> <p> content linked_page div </p> </div> and [jsfiddle] (http://jsfiddle.net/ccwsy5z4/)
could give me hand this, guys?
so found out problem js stopped working after ajax started clicking on save button.
and solution recall js function after ajax finished job. first had give name js function, called after that, , call again after ajax stopped. this:
jquery(document).ready(function($) { function radiobuttonshow() { if($(this).attr("value")=="link_to_image") { $(".radio-option").hide(); $(".linked-image").show(); } if($(this).attr("value")=="link_to_page") { $(".radio-option").hide(); $(".linked-page").show(); } }; $('input[type="radio"]').click(radiobuttonshow); $(document).ajaxstop(function() { $('input[type="radio"]').click(radiobuttonshow); }); }); hope may useful :)
Comments
Post a Comment