Note that there are some explanatory texts on larger screens.

plurals
  1. POFading out and in with $(this).parent().find() repeating
    primarykey
    data
    text
    <p>I've been creating a checklist webapp using JQuery, and so far it has been going pretty smooth, but now I'm trying to make editable content. I want to do this by fading out the text in the list, and fading in the textbox, and then reverse when complete. The checklist can be found here: <a href="http://kod.singaming.net/list/Blockquote" rel="nofollow noreferrer">The Checklist</a>. As you can see it is fairly blank, with a simple add and remove all. When you click add it runs this:</p> <pre><code>$('#add').click(function(){ $('#checklist').append( '&lt;li class="item"&gt;&lt;span class="text"&gt;&lt;cnt class="content"&gt;Text&lt;/cnt&gt;&lt;input type="text" name="tester" class="editor" /&gt;&lt;edt class="edit"&gt;E&lt;/edt&gt;&lt;/span&gt;&lt;c&gt;-&lt;/c&gt;&lt;input type="checkbox" class="done"/&gt;&lt;/li&gt;' ); </code></pre> <p>This creates the list item just fine.</p> <p>Fast forwarding, when you add one, edit it, and finish editing it works fine. If you add a bunch, say 5 at once, and then you try editing one of the top ones; it will switch to the textbox just fine, but when you finish editing it fades out and back in again.</p> <p>I believe this has to do with my selectors, this is how I am working it:</p> <pre><code>$(".text &gt; .edit").click(function(){ console.log ("You're doing it right"); //console.log ($(this).parent()); if ($(this).parent().find('.content').is(':visible') ) { var editvar = $(this).parent().find('.content').text(); $(this).parent().find('.content').fadeOut('slow'); $(this).parent().find('input[name="tester"]').val(editvar); $(this).parent().find('.editor').fadeIn('slow'); //console.log(editvar); } //if ($(this).parent().find('.content').is(':hidden') ) { else{ console.log("You're doing it wrong"); var editvar = $(this).parent().find('input[name="tester"]').val(); $(this).parent().find('.editor').fadeOut('slow'); $(this).parent().find('.content').text(editvar); $(this).parent().find('.content').fadeIn('slow'); //console.log(editvar); } }); </code></pre> <p>As you can see I am jumping from the E (edit) back to it's parent and then searching for the editable content to see if it is visible. I believe it is my selectors due to it repeating my console.logs. </p> <p>I know this isn't the most clean way, but I'm relatively new to JQuery and am trying to learn.</p> <p>Any ideas? Thanks.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload