Easily learn how to drag the jQuery plug-in EasyUIEasyUI _ jquery

Source: Internet
Author: User
This article helps you easily learn the jQuery plug-in EasyUI and use EasyUI to implement basic drag operations. The article also provides a simple example of a school curriculum, if you are interested, you can refer to this tutorial to show you how to drag HTML elements. In this example, we will create three DIV elements and then enable them to drag and place them.

First, we create three

Element:

For the first> p <元素,我们通过默认值让其可以拖动。
$ ('# Dd1'). draggable ();
For the second

Element, we can drag it by creating a proxy for cloning the original element.

$('#dd2').draggable({ proxy:'clone'});

For the third

Element. we can drag it by creating a custom proxy.

$('#dd3').draggable({ proxy:function(source){ var p = $('

proxy

'); p.appendTo('body'); return p; }});

The following is a simple example of the school curriculum:

We will create two tables: show the school subjects on the left and show the timetable on the right. You can drag a school subject and place it on a timetable cell. The school subject is

Element. The time table cell isElement.

Show school subjects

English

Science

Show time table

Monday Tuesday Wednesday Thursday Friday
08:00

Drag the school subject on the left

$('.left .item').draggable({ revert:true, proxy:'clone'});


Place School subjects on the timetable cell

$('.right td.drop').droppable({ onDragEnter:function(){ $(this).addClass('over'); }, onDragLeave:function(){ $(this).removeClass('over'); }, onDrop:function(e,source){ $(this).removeClass('over'); if ($(source).hasClass('assigned')){  $(this).append(source); } else {  var c = $(source).clone().addClass('assigned');  $(this).empty().append(c);  c.draggable({  revert:true  }); } }});

As you can see in the code above, the onDrop callback function is called when you drag the school account on the left and place it in the timetable cell. We cloned the dragged source element from the left and attached it to the time table cell. When you drag a school subject from a cell in the timetable to another cell, you just need to move it.

The above shows you how to use jQuery EasyUI to create a school curriculum. I hope it will be helpful to your learning and everyone will like it. I will continue to pay attention to the next article in Xiaobian.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.