jQuery EasyUI drop - Creating school curriculum

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.

Display school subjects

	<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>

Show Timeline

	<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>

Drag to the left of school subjects

	$ ( '. Left .item'). Draggable ({
		revert: true,
		proxy: 'clone'
	});

School subjects placed in a cell on timetable

	$ ( '. 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.

Download jQuery EasyUI examples

jeasyui-dd-timetable.zip