Click here to Skip to main content
15,886,830 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I want to make Drag & drop web builder. I am using the script to drag and drop the images from one place to another. but they are placing after then other. I need the script to freely place where ever I want.
The script I am using is ""
 <script type="text/javascript"><br />
        $(function () {<br />
            $("#dvSource img").draggable({<br />
                revert: "invalid",<br />
                refreshPositions: true,<br />
                drag: function (event, ui) {<br />
                    ui.helper.addClass("draggable");<br />
                },<br />
                stop: function (event, ui) {<br />
                    ui.helper.removeClass("draggable");<br />
                    var image = this.src.split("/")[this.src.split("/").length - 1];<br />
                    if ($.ui.ddmanager.drop(ui.helper.data("draggable"), event)) {<br />
                        <br />
                    }<br />
                    else {<br />
                      <br />
                    }<br />
                }<br />
            });<br />
            $("#dvDest").droppable({<br />
                drop: function (event, ui) {<br />
                    if ($("#dvDest img").length == 0) {<br />
                        $("#dvDest").html("");<br />
                    }<br />
                    ui.draggable.addClass("dropped");<br />
                    $("#dvDest").append(ui.draggable);<br />
                }<br />
            });<br />
        });<br />
    </script><br />
<br />


and

<br />
<pre lang="xml"><div id="dvSource"><br />
        <img alt="" src="images/Chrysanthemum.jpg" /><br />
        <img alt="" src="images/Desert.jpg" /><br />
        <img alt="" src="images/Hydrangeas.jpg" /><br />
        <img alt="" src="images/Jellyfish.jpg" /><br />
        <img alt="" src="images/Koala.jpg" /><br />
        <img alt="" src="images/Lighthouse.jpg" /><br />
        <img alt="" src="images/Penguins.jpg" /><br />
        <img alt="" src="images/Tulips.jpg" /><br />
    </div><br />
    <hr /><br />
    <div id="dvDest"><br />
        Drop here<br />
    </div></pre><br />
<br />
<br />
Posted

1 solution

You should try using jQueryUI. It contains some beautiful UI functionalities include Drag-n--drop with minimal coding.
 
Share this answer
 
Comments
saqib mahay 5-Dec-14 6:22am    
Actually I want to develop the Drag & Drop CMS. The magazine creator. Is it Good technique to use JQUERYUI ?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900