使多选列表可调整大小

亨里克

如何使此多选列表可调整大小?我想设置列表的默认高度和宽度以及最小高度和宽度,但是可以自行调整大小。

我试过这个没有成功:

<div id="resizable" class="ui-widget-content">
   <h3 class="ui-widget-header">Stored Procedures</h3>
<div class='list'> 

<select multiple="multiple" height="5" data-bind="options:storedProceduresInDB1, selectedOptions:selectedStoredProceduresInDb1"> </select>

<div>
    <button data-bind="click: copyToDb2, enable: selectedStoredProceduresInDb1().length > 0">Copy to DB2</button>
</div>
</div>
</div>


$(function() {
    $( "#resizable" ).resizable();
});

JSFiddle

布赖恩

在您的jsFiddle中,我看不到,$('#resizable').resizable();并且您没有ID为的任何内容resizable但是,由于您已使用jQuery对其进行了标记,因此可以通过包含jQuery .js和.css文件来完成此操作。另外,将ID的IDresizable调整为可调整大小并引用插件。要设置最小高度和宽度,请参见下面的代码。我对jsFiddle的更改包括:

  1. 已添加id="resizable"到您的select
  2. 添加 $( "#resizable" ).resizable();
  3. 将jQuery的.css文件添加到外部资源
  4. 将jQuery的.js文件添加到HTML
  5. (可选)要调整拖动器的位置,请添加此CSS .ui-resizable-se { bottom: 'some amount'; right: 'some amount'; }

这是一个更新的jsFiddle,其中不包括我提到的css或设置最小高度和宽度。

和代码:

<select id="resizable" multiple="multiple" height="5" 
    data-bind="options:storedProceduresInDB1, 
    selectedOptions:selectedStoredProceduresInDb1"></select>

$(function() {
    $('#resizable').resizable({
        // to set the min height and width
        minHeight: 100,
        minWidth: 200
        // you could also set a maxHeight and maxWidth as well
    });
});

要将拖动器图标放置在中select,我添加了以下CSS:

.ui-resizable-se { bottom: 18px; right: 25px; }

本文收集自互联网,转载请注明来源。

如有侵权,请联系[email protected] 删除。

编辑于
0

我来说两句

0条评论
登录后参与评论

相关文章