1

I've been looking through a lot of tutorials on jQuery draggable and trying to apply it to ASP.NET MVC, but I am really confused.

Does anyone know of some simpler samples.

@model locat.Models.LoginModel

@{

    ViewBag.Title = "Log in";
}


    @using (Html.BeginForm(null, null, FormMethod.Post, new { id = "msform" }))
    {
        @Html.AntiForgeryToken()
        @Html.ValidationSummary()

        <!-- fieldsets -->
    <div id="drag">
        <fieldset>
            <h2 class="fs-title">Login</h2>
            <h3 class="fs-subtitle"></h3>

            <input name="UserName" type="text" placeholder="Username">
            <input name="Password" type="Password" placeholder="Password">
            <input type="button" name="next" class="next action-button" value="New User" />

            <input type="submit" name="next" class="nexts action-login" value="Log in" />
        </fieldset>

    </div>
    }

<script>
    $(function () {
        $("#drag").draggable();
    });
</script>

    @section Scripts {
        @Scripts.Render("~/bundles/jqueryval")
        @Scripts.Render("~/bundles/jqueryui")
    }
7
  • include js files also. Commented Jul 26, 2014 at 6:56
  • is there is any errors in console?? Commented Jul 26, 2014 at 7:03
  • got nothing : smiply it displays the element alone.can't able to drag Commented Jul 26, 2014 at 7:05
  • have u included jquery and jquery-ui files??? Commented Jul 26, 2014 at 7:06
  • add these files in ur head tag.<script src="//ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script> <script src="//ajax.googleapis.com/ajax/libs/jqueryui/1.9.1/jquery-ui.min.js"></script> <link rel="stylesheet" href="code.jquery.com/ui/1.9.1/themes/base/jquery-ui.css" /> Commented Jul 26, 2014 at 7:28

2 Answers 2

1

You have one of these problems :-

  1. Your jQuery or jQuery UI Javascript path files are wrong.

  2. Your jQuery UI does not include draggable.

  3. Your div is unstyled or empty, therefore there is nothing to drag.

  4. Something is colliding with your jQuery or jQuery UI so it doesn't work.

In your question ur div with id="drag" in not styled so give style to it so that draggable will work on it.

Sign up to request clarification or add additional context in comments.

1 Comment

Thank you very much Kartikeya Khosla : Now its working greatly. The problem is its not styled.
0

ut your dragable elements inside Ul as below and don't forget to include Jquery UI files reference:

<ul id="sortable">
  <li class="ui-state-default">Item 1</li>
  <li class="ui-state-default">Item 2</li>
  <li class="ui-state-default">Item 3</li>
  <li class="ui-state-default">Item 4</li>
 <li class="ui-state-default">Item 5</li>
</ul>

AND Jquery:

$(function() {
  $( "#sortable" ).draggable({       
  });     
});

Working Demo Is Here http://jsfiddle.net/booyaa/YvJhE/

2 Comments

Thank u very much Pawan .Now its Working greatly:

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.