Page
4 methodsjQuery Mobile 页面模型:data-role='page' 容器、编程式页面切换和过渡。
$(el).draggable(options?)以编程方式从当前页面过渡到另一页面或 URL。
Parameters
| Name | Type | Description |
|---|---|---|
| options | object | Optional { handle, axis, containment, grid, revert, ... }. |
Returns
jQuery
Example
jquery-ui
$('.box').draggable({
handle: '.drag-handle',
containment: 'parent',
grid: [10, 10],
});$(el).droppable(options?)将容器标记为移动应用中单个页面的属性。页面一次显示一个。
Parameters
| Name | Type | Description |
|---|---|---|
| options | object | Optional { accept, hoverClass, drop(event, ui), ... }. |
Returns
jQuery
Example
jquery-ui
$('.trash').droppable({
accept: '.item',
drop: function (event, ui) {
ui.draggable.remove();
},
});$(el).sortable(options?)链接或按钮上设置页面过渡动画的属性。
Parameters
| Name | Type | Description |
|---|---|---|
| options | object | Optional { items, placeholder, connectWith, update, ... }. |
Returns
jQuery
Example
jquery-ui
$('ul.todos').sortable({
placeholder: 'placeholder',
update: function () {
console.log('order changed');
},
});instance('option', key, value)以编程方式导航到 URL,同时与 hashchange 历史状态集成。
Parameters
| Name | Type | Description |
|---|---|---|
| key | string | Option name. |
| value | any | New value (omit to get). |
Returns
any | jQuery
Example
jquery-ui
$('.box').draggable('option', 'axis', 'x');Widgets
4 methods触摸优化的 jQuery Mobile 部件:listview、navbar 和 popup。
$(el).accordion(options?)将 ul/ol 增强为带样式的移动列表视图。支持 inset、split 和 filter 选 项。
Parameters
| Name | Type | Description |
|---|---|---|
| options | object | Optional { active, collapsible, heightStyle, ... }. |
Returns
jQuery
Example
jquery-ui
$('#acc').accordion({
collapsible: true,
heightStyle: 'content',
});$(el).datepicker(options?)将链接的 ul 增强为 jQuery Mobile 导航栏(最多 5 个均匀分布的项)。
Parameters
| Name | Type | Description |
|---|---|---|
| options | object | Optional { dateFormat, minDate, maxDate, onSelect, ... }. |
Returns
jQuery
Example
jquery-ui
$('#dob').datepicker({
dateFormat: 'yy-mm-dd',
maxDate: 0,
});$(el).dialog(options?)将内容包装为覆盖页面的弹出层。使用 popup('open') 打开。
Parameters
| Name | Type | Description |
|---|---|---|
| options | object | Optional { modal, buttons, width, height, autoOpen, ... }. |
Returns
jQuery
Example
jquery-ui
$('#dlg').dialog({
modal: true,
buttons: { OK: function () { $(this).dialog('close'); } },
});$(el).tabs(options?)通过在元素上调用方法来编程式打开或关闭部件(popup、dialog)。
Parameters
| Name | Type | Description |
|---|---|---|
| options | object | Optional { active, collapsible, event, ... }. |
Returns
jQuery
Example
jquery-ui
$('#tabs').tabs({
active: 1,
event: 'mouseover',
});