Saturday, July 15, 2017

Part 41 - How to create responsive sortable image gallery using Jquery-UI



In this video you will be able to create responsive sortable photo gallery. for that you need to download latest version of Jquery UI . Click here to download the latest version of Jquery-UI
The latest version will only be compatible with higher version of Jquery i.e.  Jquery 1.7+ .
After downloading the latest version, add the .css , .js file and images into your project. In case if you find any problem the follow the  steps as shown in the above video. The expected output will be as what displayed in following image. 
Our main objective is that, we have to sort the sequence of the below image by dragging and dropping method. For that we can use the .sortable() method offered by JQuery-UI 





 # View Page (Index.cshtml)

Right click on your controller' s Index method and add a view. After adding view, replace content with below code.  
Please follow below points: 
1. Please take an equal size of images or else you can set equal height and width for all images. 
2. Make sure to replace below images with your images.
3. Don't forget to give reference of JQuery-UI  .jss , .css file reference into your layout page


<div class="panel panel-body" style="min-height:256px">
  
    <div class="col-md-9">
        <h4>Technotips MVC tutorial</h4>

        <ul class="list-group" id="SortableGallery" style="cursor:move">
            <li class="list-group-item col-md-4" >
                <div>
                    <img class="img-responsive" src="~/Content/images/vocal.jpg" />
                </div>
            </li>
            <li class="list-group-item col-md-4">
                <div>
                    <img class="img-responsive" src="~/Content/images/voiline.jpg" />
                </div>
            </li>
          
            <li class="list-group-item col-md-4">
                <div>
                    <img class="img-responsive" src="~/Content/images/tabla.jpg" />
                </div>
            </li>
            <li class="list-group-item col-md-4">
                <div>
                    <img class="img-responsive" src="~/Content/images/social.jpg" />
                </div>
            </li>
            <li class="list-group-item col-md-4">
                <div>
                    <img class="img-responsive" src="~/Content/images/onlinebookstore.jpg" />
                </div>
            </li>
            <li class="list-group-item col-md-4">
                <div>
                    <img class="img-responsive" src="~/Content/images/mobile.jpg" />
                </div>
            </li>
        </ul>

    </div>

</div>

<script>

    $("#SortableGallery").sortable({

        update: function () {

            alert("Wow");
        }
    });

</script>


All Code Factory

No comments: