September 4, 201312 yr Hello, picture the scene... On my website i have database blog posts echoed out. They look like so: <div id="blogtest"> <form><input type="button" id="editbutton" class='.$editenabled.' value="Edit"></form> <div id="text"> <div id="buildtext">'.$text.'</div> <div id="ckeditor"> <textarea id="ckeditor" name="ckeditor" class="ckeditor">'.$text.'</textarea> <script type="text/javascript"> CKEDITOR.replace( ".ckeditor" ); </script> </div> </div> </div> I am using this javascript code: <script> $(document).ready(function(){ $("#editbutton").click(function() { $('#buildtext').toggle('hide'); $('#ckeditor').toggle('show'); }); }); </script> Now on my test page i have 2 results that are echoed. Currently the ckeditor div is hidden via css display none. If i click the edit button on my first blog output the text is hidden and the ckeditor is displayed fine. However the second result doesnt work. When the edit button is pressed nothing happens. Any help on this?
September 5, 201312 yr Author Tried doing it last night but it didnt work, if i dont have the editor as hidden they both show fine.Just the javascript button doesnt work.Doesnt even hide the text.
September 5, 201312 yr Author any reason why this wont work? $(document).ready(function(){ $(".editbutton :button").click(function () { $('.buildtext',this).toggle('hide'); }); }); it works if i say have a click function for blogtest div, but the button wont work. http://jsfiddle.net/TSMcz/ Edited September 5, 201312 yr by Lovelock
September 5, 201312 yr Author Once transffering a working jsfiddle to my actual page its not working. The two buttons are working fine but the other divs are not showing / hiding... any help? here a jsfiddle http://jsfiddle.net/JSX7b/
September 5, 201312 yr You are searching the parent of the buttons (the form) for .ckeditor and .buildtext, but they are not there.
Create an account or sign in to comment