【发布时间】:2023-03-09 00:17:01
【问题描述】:
嗯,我正在开发一个可视化表单设计器,并决定使用 jQuery UI 作为最终表单小部件集以及设计器本身的小部件集。
我主要关心的是让 jQuery wigets “只读”。我有以下想法:
<style type="text/css">
.widget-wrap { position: relative; }
.widget-overlay { position: absolute; left:0; right:0; top:0; bottom:0; /*maybe z-index as well*/ }
</style>
<div class="widget-wrap" id="wdt1">
<button class="jquery-widget">Hello World!</button>
<div class="widget-overlay"><!----></div>
</div>
<script type="text/javascript">
$(function() {
$("button.jquery-widget").button();
});
function widgetLock(){
$("#wdt1 .widget-overlay").show();
}
function widgetRelease(){
$("#wdt1 .widget-overlay").hide();
}
</script>
希望我的例子有意义:)
我的问题是;
- 这听起来不错吗?
- 您知道更好的方法还是其他方法?
- 您认为它有任何可能的问题吗?
【问题讨论】:
-
尝试禁用按钮或通过 HTML 将内容设为只读,而不是将 div 粘贴到顶部
-
@Raynos - 我不够清楚;我的解决方案需要适用于所有可能的小部件,而不仅仅是那些碰巧具有禁用属性的小部件。
-
@ChristianSoberras 然后我建议使用这些小部件“禁用”功能检测,并降级为没有“本机”禁用的隐藏 div。
-
@Raynos - 我担心禁用它可能会改变风格,我真的不希望这种情况发生。但是,我保留了这个选项。
标签: javascript jquery forms designer