Note that there are some explanatory texts on larger screens.

plurals
  1. POJquery: Sortable inside a slidetoggle div
    text
    copied!<p>I am building a new UI using jquery and I am having some trouble using .sortable inside a div that is displayed using slide toggle. Here is the HTML (MVC Razor):</p> <pre><code>&lt;div style="float:left; width:200px; margin-right:5px" &gt; &lt;div class="FeaturesContainer"&gt; &lt;b&gt;Project backlog&lt;/b&gt;&lt;br /&gt; @foreach (var feature in Model.Managment.tasksByFeature) { if (feature.Value.Count != 0) { &lt;div class="FeatureContainer"&gt; &lt;div class="FeatureHeading" id="@feature.Key.id"&gt; &lt;div class="icon" style="float:right"&gt; &lt;img width="20" src="../../Content/images/down.png" /&gt; &lt;/div&gt; &lt;span class="FeatureTitle"&gt;@feature.Key.summary&lt;/span&gt; &lt;/div&gt; &lt;div class="Feature"&gt; &lt;ul class="drop"&gt; @foreach (var task in feature.Value) { &lt;li class="taskItem"&gt; @Html.ActionLink(task.summary, "Task", new { proj = Model.Managment.project.Id, id = task.id })&lt;br /&gt; Effort: @task.Effort &lt;/li&gt; } &lt;/ul&gt; &lt;/div&gt; &lt;/div&gt; } } &lt;/div&gt; &lt;/div&gt; &lt;div style="float:left; width:190px;"&gt; &lt;div class="SprintContainer" id="@Model.Managment.sprint.Id"&gt; &lt;b&gt;Tasks for this sprint&lt;/b&gt;&lt;br /&gt; &lt;ul class="drop"&gt; @foreach (var task in Model.Managment.tasksInSprint) { &lt;li class="taskItem"&gt; @Html.ActionLink(task.summary, "Task", new { proj = Model.Managment.project.Id, id = task.id })&lt;br /&gt; Effort: @task.Effort &lt;/li&gt; } &lt;/ul&gt; Max Effort: @Model.Metrics.Velocity&lt;br /&gt; Total Effort: @Model.Managment.tasksInSprint.Sum(i =&gt; i.Effort) &lt;/div&gt; &lt;/div&gt; </code></pre> <p>And the revlevent CSS:</p> <pre><code>.drop { list-style-type: none; margin: 0; float: left; margin-right: 5px; background: #eee; padding: 5px; width: 158px; min-height:75px; } .drop li { padding: 5px; font-size: .9em; width: 145px; cursor:move; } .highlight { border: 1px dashed #3E3E3E; height:50px; margin-bottom:2px; } .FeaturesContainer { background-color:#FFFFFF; border: 2px solid #3E3E3E; color:#FE7F00; padding:5px; -moz-border-radius: 4px; border-radius: 4px; margin: 0 0 10px 0; } .SprintContainer { background-color:#FFFFFF; border: 2px solid #3E3E3E; color:#FE7F00; padding:5px; -moz-border-radius: 4px; border-radius: 4px; margin-bottom:10px; margin-right: 5px; } .FeatureContainer { background-color:#BEBEBE; border: 1px solid #3E3E3E; color:#FE7F00; padding:5px; margin-bottom:10px; margin-top:5px; margin-right: 5px; } .FeatureHeading { padding: 5px 10px; cursor: pointer; position: relative; margin:1px; color:#FFFFFF; background-color:#006600; border-left: 1px solid #3E3E3E; border-right: 1px solid #3E3E3E; border-top: 1px solid #3E3E3E; } .Feature { padding:0; margin:0 0 0 0; position:relative; border-left: 1px solid #3E3E3E; border-right: 1px solid #3E3E3E; border-bottom: 1px solid #3E3E3E; } </code></pre> <p>And the jQuery:</p> <pre><code>$(function () { $("ul.drop").sortable({ connectWith: "ul", dropOnEmpty: true, placeholder: "highlight" }); }); $(document).ready(function () { var visible = true; $(".Feature").hide(); $(".FeatureHeading").click(function () { $(this).next(".Feature").slideToggle(function () { visible = !visible; $(this).css({'height': 'auto'}) if (visible) { $('img', this).attr('src', '../../Content/images/down.png'); } else { $('img', this).attr('src', '../../Content/images/up.png'); } }); }); }); </code></pre> <p>The problem is, when I click the FeatureHeading, the Feature slides down as expected, but as soon as the animation is complete it immediately collapses, yet the content of the Feature div is still visible. The list items are still draggable, and I can drop them in the Sprintcontainer. </p> <p>If I add overflow:hidden to the Feature, the feature will display as desired, however as soon as I try to drag a list item to the SprintContainer the item seems to go behind the FeatureContainer and I can’t see it being dragged until I release the mouse over the sprint container, at which point the list item appears in the sprint container as expected.</p> <p>Is it possible to have a sortable list inside a slidetoggle div?</p>
 

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