Thursday, 15 March 2012

jquery - Trying to get appended button to display block hidden element within a set and close all others -


I have three field sets that are displayed once in a while, while clicking on the Continue button Is clicked on. I am adding another edit button to recently closed FieldSet parent. The purpose of the editing button is to allow anyone to open that specific field.

I have a problem when the edit button is clicked and the field does not open within that set. If I just use the following code without the rest of the code, then it works fine, so I'm not sure why it works with the rest:

  $ ('. Edit '). Click (function () {$ (this) .closest (' .ap_section block '). ("Field") Search Toggle ();}); Here is the code I am using:  

Any help would be appreciated. Thank you.

You need to use an event delegation, your editing button is dynamically created and DOM Has been added. But your click events are not ready when they still do not exist. Therefore, attach this event to the document head or any other container present in the dot at another time, so that the event is handed over to the edit button created from the specified container in the future.

  $ ('.ap_private_party_form') ('Click', 'Edit', function () {$ (this) .closest ('.ap_section block'). ("Field" "). Show ();});   

For the use of older versions, for the 1.7+ version of jquery use.

Updates to your continued release
  $ ('. Close' (function () (var $ this = $ (this); $ this.closest ( 'Fieldset'). Hide (); var $ block = $ this.closest (".p_sectionblock" $ block.find ('.p_sectionheader'). Enclosed ('& lt; span & gt; & lt; input type =' Button "square =" edit "value =" edit "& gt; & lt; / span & gt; '); $ Block.next (" .ap_sectionblock "). (" Field "). Show (); (Return '); $ (' .ap_private_party_form '). (' Click ',' .edit ', function () {$ (' .ap_section block '). (' Fieldset: Visible '). ; // Now set the field that any number Are shown on the click of the order, so that only one time can be shown. $ (This) .closest ('.ap_sectionblock'). ("Field"). Show (); // field to show it $ $ (This) .remove (); // Delete the edit button, because you do not want it more on the edited page.});   



No comments:

Post a Comment