HTML tutorial
CSS3 tutorial
Bootstrap tutorial
JavaScript tutorial
JQuery tutorial
AngularJS tutorial
React tutorial
NodeJS tutorial
PHP tutorial
Python tutorial
Python3 tutorial
Django tutorial
Linux tutorial
Docker tutorial
Ruby tutorial
Java tutorial
C tutorial
C ++ tutorial
Perl tutorial
JSP tutorial
Lua tutorial
Scala tutorial
Go tutorial
ASP.NET tutorial
C # tutorial
This tutorial will show you how to create a school curriculum using jQuery EasyUI. We will create two tables: school subjects displayed on the left to display the schedule on the right. You can drag and school subjects placed on the schedule cell. School subjects is a <div class = "item"> element, the cell is a timetable <td class = "drop"> element.
<Div class = "left"> <Table> <Tr> <Td> <div class = "item"> English </ div> </ td> </ Tr> <Tr> <Td> <div class = "item"> Science </ div> </ td> </ Tr> <-! Other subjects -> </ Table> </ Div>
<Div class = "right"> <Table> <Tr> <Td class = "blank"> </ td> <Td class = "title"> Monday </ td> <Td class = "title"> Tuesday </ td> <Td class = "title"> Wednesday </ td> <Td class = "title"> Thursday </ td> <Td class = "title"> Friday </ td> </ Tr> <Tr> <Td class = "time"> 08:00 </ td> <Td class = "drop"> </ td> <Td class = "drop"> </ td> <Td class = "drop"> </ td> <Td class = "drop"> </ td> <Td class = "drop"> </ td> </ Tr> <-! Other cells -> </ Table> </ Div>
$ ( '. Left .item'). Draggable ({ revert: true, proxy: 'clone' });
$ ( '. 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 above code, when a user drags on the left side of the school subjects and placed in a cell in the timetable, onDrop callback function will be called. We cloned the drag source element from the left side and attach it to the schedule cell. When dragged from the school subject schedule a cell to another cell, simply move it to.