Note that there are some explanatory texts on larger screens.

plurals
  1. POJquery Drag Element after changing through dialog when dragged gets to orignal default state
    primarykey
    data
    text
    <p>i have this drag drop code for my elements</p> <pre><code>$( ".sortable" ).sortable({ revert: true }); $( ".draggable" ).draggable({ connectToSortable: ".sortable", helper: "clone", //clone revert: "true" }); $( ".sortable" ).droppable({ drop: function( event, ui ) { var $element = $(ui.draggable).clone(); $element.find('.control').children('.delete').css('display', 'inline').click(function () { $(this).parent().remove(); });// display properties Link $element.find('.control').children('.properties').css('display', 'inline'); //For Text Box Change the text and add a label if($element.find('.control').find('input').attr('type') == "text") { $element.find('.control').find('.controlText').html(""); $element.find('.control').find('label').html("Label Here"); } } }); </code></pre> <p>This is the code for the drag element</p> <pre><code> &lt;div class="tools"&gt; &lt;ul&gt; &lt;li class="draggable" &gt; &lt;div class="control"&gt; &lt;label&gt;&amp;nbsp;&lt;/label&gt; &lt;input type="text" name="txt" value="" /&gt;&lt;span class="controlText"&gt; Text Box &lt;/span&gt; &lt;div class="delete" style="display:none"&gt;&lt;sup&gt;x&lt;/sup&gt;&lt;/div&gt; &lt;div class="properties txtbox" style="display:none"&gt;Properties&lt;/div&gt; &lt;/div&gt; &lt;/li&gt; &lt;/ul&gt; &lt;/div&gt; </code></pre> <p>When the Text Box is dragged this event is attached to it </p> <pre><code>$('.txtbox').live('click', function() { //get the label var label = $(this).parent().find('label').html(); $("#textbox_label").val(label); $( "#dialog-textbox" ).dialog( "open" ).data('parent_div',$(this).parent()); return false; }); </code></pre> <p>This is the dialog which opens when the Properties is clicked</p> <pre><code>&lt;div id="dialog-textbox" title="Text Box Properties" style="display:none"&gt; &lt;p&gt;This is the Text Box Properties Form.&lt;/p&gt; &lt;form&gt; &lt;fieldset&gt; &lt;label for="textbox_label"&gt;Enter Label &lt;/label&gt; &lt;input type="text" name="textbox_label" id="textbox_label" class="text ui-widget-content ui-corner-all" /&gt; &lt;/fieldset&gt; &lt;/form&gt; </code></pre> <p></p> <p>The following code handles the Dialog</p> <pre><code> $("#dialog-textbox").dialog({ autoOpen: false, height: 300, width: 350, modal: true, buttons: { "Apply": function(){ //code to update element goes here... var label = $("#textbox_label").val() var $elem_clicked = $("#dialog-textbox").data('parent_div'); //This retrieves $elem_clicked.find('label').html(label); $( this ).dialog( "close" ); }, Cancel: function() { $( this ).dialog( "close" ); } } }); </code></pre> <p>What is happening here is that i have a text box which i drag to a ul li list and that is sortable, the text box is added to the list and and then i show and close and properties links attached to the text box. when the properties is clicked a dialog box opens and asks for a new label. user gives new label to the text box that is shown with that. But what goes wrong is when i again drag the box in the sortable list up or down it goes back to its initial state and the new label is lost... I think this is due to the helper clone or should i make a clone of the draggable item?</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.
    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