import jquery, easyui and more scripts in aspx
This is strange problem. I want to use easyuis drad-and-drop capabilities, so I need to import jquery and easyui libs in aspx page. This should be fairly easy, but...
I tried many times with code like this
<hea开发者_运维知识库d>
<script src="Scripts/jquery-1.4.1.min.js" type="text/javascript"></script>
<script src="Scripts/jquery.easyui.min.js" type="text/javascript"></script>
<script src="Scripts/drag_and_drop.js" type="text/javascript"></script>
</head>
where drag_and_drop.js is
function OnDrag() {
$('module1').draggable();
};
and i call function here
<body>
<div id="module1" runat="server" oninit="OnDrag()">
<asp:Panel ID="Panel1" runat="server">
<asp:Image ID="Image1" runat="server" ImageUrl="~/Resources/mickey.jpg" />
</asp:Panel>
</div>
</body>
This all do not work for some reason.
I tried pasting entire libs of jquery and easyui in script tag inside head tag, and everything worked fine. This made me understand that there is problem with importing libs to aspx.
What I am doing wrong? Thank you in advance...
Remove the oninit
from the div tag, then add this bit of code in your head of the page.
<script type="text/javascript">
$(function(){
$('module1').draggable();
});
</script>
This will run the draggable()
method when the DOM is ready, and should work
EDIT Try using the jQuery-UI draggable instead. http://jqueryui.com/demos/draggable/
You can then get rid of your jquery.easyui.min.js and drag_and_drop.js scripts.
精彩评论