|
Slyweb
|
|
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<link href="jquery-ui-1.7.2.custom.css"
rel="stylesheet" type="text/css"/>
<script src="jquery-1.3.2.min.js"></script>
<script src="jquery-ui-1.7.2.custom.min.js"></script>
<script>
$(document).ready(function(){
$(function() {
$("#draggable").draggable();
$("#droppable").droppable({
drop: function(event, ui) {
$(this).addClass('ui-state-highlight').find('p').html('Объект принят!');
}
});
});
});
</script>
</head>
<body class="iframe">
<div class="demo">
<div id="draggable" class="ui-widget-content">
<p>Перетащи меня в мой объект</p>
</div>
<div id="droppable" class="ui-widget-header">
<p>Поместить здесь</p>
</div>
</div><!-- End demo -->
<div style="display: none;" class="demo-description">
<p>Enable any DOM element to be droppable,
a target for draggable elements.</p>
</div><!-- End demo-description -->
</body>
</html>
<style>
#draggable { width: 70px; height: 70px;
padding: 0.5em; float: left; margin: 10px 10px 10px 0; }
#droppable { width: 100px; height: 100px;
padding: 0.5em; float: left; margin: 10px; }
</style>
Опция: accept
$('.selector').droppable({ accept: '.special' });
//Получить опцию
var accept = $('.selector').droppable('option', 'accept');
//Установить опцию
$('.selector').droppable('option', 'accept', '.special');
Опция: activeClass
$('.selector').droppable({ activeClass: false });
//получить опцию
var addClasses = $('.selector').droppable('option', 'activeClass');
//установить опцию
$('.selector').droppable('option', 'activeClass', false);
Опция: addClasses
$('.selector').droppable({ addClasses: false });
//получить опцию
var addClasses = $('.selector').droppable('option', 'addClasses');
//установить опцию
$('.selector').droppable('option', 'addClasses', false);
Опция: greedy
$('.selector').droppable({ greedy: true });
//получить опцию
var greedy = $('.selector').droppable('option', 'greedy');
//установить опцию
$('.selector').droppable('option', 'greedy', true);
Опция: hoverClass
$('.selector').droppable({ hoverClass: 'drophover' });
//получить опцию
var hoverClass = $('.selector').droppable('option', 'hoverClass');
//установить опцию
$('.selector').droppable('option', 'hoverClass', 'drophover');
Опция: scope
$('.selector').droppable({ scope: 'tasks' });
//получить опцию
var scope = $('.selector').droppable('option', 'scope');
//установить опцию
$('.selector').droppable('option', 'scope', 'tasks');
Опция: tolerance
$('.selector').droppable({ tolerance: 'fit' });
//получить опцию
var tolerance = $('.selector').droppable('option', 'tolerance');
//установить опцию
$('.selector').droppable('option', 'tolerance', 'fit');
Событие: activate
$('.selector').droppable({
activate: function(event, ui) { ... }
});
$('.selector').bind('dropactivate', function(event, ui) {
...
});
Событие: deactivate
$('.selector').droppable({
deactivate: function(event, ui) { ... }
});
$('.selector').bind('dropdeactivate', function(event, ui) {
...
});
Событие: over
$('.selector').droppable({
over: function(event, ui) { ... }
});
$('.selector').bind('dropover', function(event, ui) {
...
});
Событие: out
$('.selector').droppable({
out: function(event, ui) { ... }
});
$('.selector').bind('dropout', function(event, ui) {
...
});
Событие: drop
$('.selector').droppable({
drop: function(event, ui) { ... }
});
$('.selector').bind('drop', function(event, ui) {
...
});
Метод: destroy
Метод: disable
Метод: enable
Метод: option
Используемая тема jQuery UI
Образец разметки jQuery UI CSS струтктуры классов
<div class="ui-draggable"></divУчтите: Данный образец разметки сгенерирован через плагин draggable,это не разметка которую вы можете использовать для создания перемещения. Единственная необходимая разметка - <div></div>.