未设置jquery.ui.dialog选项
我不知道如何为jquery.ui.dialog设置draggable和resizeable选项。我有一个从主页调用的JS文件: /js/rental/add.js:未设置jquery.ui.dialog选项,jquery,cakephp-1.3,jquery-ui-dialog,Jquery,Cakephp 1.3,Jquery Ui Dialog,我不知道如何为jquery.ui.dialog设置draggable和resizeable选项。我有一个从主页调用的JS文件: /js/rental/add.js: var additempopup = null; $(document).ready(function() { var $dialog = $('#adddialog').load('additem') .dialog({ autoOpen: fals
var additempopup = null;
$(document).ready(function() {
var $dialog = $('#adddialog').load('additem')
.dialog({
autoOpen: false,
title: 'Add Item',
width: 'auto',
position: 'center',
resizeable: true,
modal: true,
draggable: true,
closeOnEscape: true,
closeText: 'close'
});
$('.jsAddItemPopup').click(function() {
$dialog.dialog('open');
return false;
});
$('#modalclose').click(function() {
$dialog.dialog('close');
return false;
});
additempopup = $dialog;
} );
它是从主页面调用的,主页面是一个cakephp视图
摘自/views/rentals/add.ctp:
<?php
$javascript->link('jquery/js/jquery-1.4.4.min', false);
$javascript->link('jquery/ui/jquery.ui.core', false);
$javascript->link('jquery/ui/jquery.ui.widget', false);
$javascript->link('jquery/ui/jquery.ui.dialog', false);
$javascript->link('jquery/rentals/add.js', false);
echo $html->css('ui-lightness/jquery-ui-1.8.9.custom');
?>
<?php
echo $html->link(
'Add Item', '#', array('title' => 'Add Item', 'class' => 'jsAddItemPopup'));
?>
<div id="adddialog" class="adddialog" style="display: none;"></div>
弹出窗口正在加载以下视图
摘录自/views/rentals/additem.ctp:
<div id='ajax-content'>
<?php
echo $ajax->form('edit', 'post', array(
'model' => 'RentalLineitem',
'url' => array( 'controller' => 'rentals', 'action' => 'additem')
)); ?>
<table>
<tr>
<td style="text-align: left;">
<?php echo $this->Form->submit('Cancel',
array('name' => 'cancel',
'onclick' => "additempopup.dialog('close'); return false;")); ?>
</td>
<td style="text-align: right;">
<?php echo $this->Form->submit('Add Item', array('name' => 'Save')); ?>
</td>
</tr>
</table>
<?php echo $this->Form->end(); ?>
</div>
一切正常,添加项链接打开模式对话框,模式对话框中的“取消”关闭窗口,“添加项”正确返回Ajax帖子,但它弹出在屏幕的右上角,而不是中间,拖动和调整大小不起作用。我想让这一切顺利进行,但我有点沮丧。我试着胡闹了一会儿,但没有用
更新:根据建议的解决方案,我缺少依赖项,我将它们添加到主页/view/rentals/add.ctp:
<?php
$javascript->link('jquery/js/jquery-1.4.4.min', false);
$javascript->link('jquery/ui/jquery.ui.core', false);
$javascript->link('jquery/ui/jquery.ui.widget', false);
$javascript->link('jquery/ui/jquery.ui.mouse', false);
$javascript->link('jquery/ui/jquery.ui.draggable', false);
$javascript->link('jquery/ui/jquery.ui.resizable', false);
$javascript->link('jquery/ui/jquery.ui.position', false);
$javascript->link('jquery/ui/jquery.ui.dialog', false);
$javascript->link('jquery/rentals/add.js', false);
echo $html->css('ui-lightness/jquery-ui-1.8.9.custom');
?>
您可能缺少ui.mouse、ui.draggable和ui.resizeable依赖项。
在上面的示例中,您拼写的
可调整大小
错误。把e
放在able
之前,你有我们可以看到的现场演示吗?页面上列出的依赖项非常清楚,我完全错过了它们。我责备这周连续18小时的工作太多了。从中吸取的教训是,在使用jquery.ui时,请务必密切注意列出的依赖项。太棒了,就是这样,该死的依赖项。而且我也缺少ui.position。这非常简单,非常感谢。这不是我的主要问题,但你是对的。幸运的是,默认值是resizeable=true,因此我的拼写错误没有影响任何东西,只是被忽略了。