我无法输入内容
我有一个可以排序的列表。我正在使用带有小部件、鼠标、位置、可排序插件的 jQuery UI。
CSS:
#sortable{
width : 550px;
display: inline-block;
}
#sortable li, #add {
width : 550px;
margin : 5px;
padding : 5px;
height : 50px;
}
#sortable li img.social-icon, #sortable li img.drag-cursor {
width: 40px;
height : 40px;
float : left;
}
#sortable li img.social-icon {
margin-right : 5px;
}
#sortable li img.drag-cursor {
margin-left : 5px;
cursor : move;
}
#sortable li input {
height:40px;
width:450px;
line-height: 45px;
float:left;
}
#add {
cursor : pointer;
text-align: center;
line-height: 45px;
}
.ui-state-highlight { height: 50px; line-height: 50px; }
HTML:
<div id="dash-wrapper">
<ul id="sortable">
<li class="ui-state-default">
<img src="images/social/twitter.png" class="social-icon" />
<input type="text" value="textt" name="user-media-link[]" class="user-media-link">
<input type="hidden" name="social-media-type" value="1">
<img src="images/drag.png" class="drag-cursor">
</li>
<li class="ui-state-default">
<img src="images/social/facebook.png" class="social-icon" />
<input type="text" value="textt" name="user-media-link[]">
<input type="hidden" name="social-media-type" value="1">
<img src="images/drag.png" class="drag-cursor">
</li>
<li class="ui-state-default">
<img src="images/social/rss.png" class="social-icon" />
<input type="text" value="textt" name="user-media-link[]">
<input type="hidden" name="social-media-type" value="1">
<img src="images/drag.png" class="drag-cursor">
</li>
</ul>
<div class="ui-state-default" onCLick="addNewSocial(); return false;" id="add">ADD</div>
</div>
脚本:
$(function() {
$("#sortable").sortable({
placeholder: "ui-state-highlight"
});
$("#sortable").disableSelection();
});
function addNewSocial() {
$("#sortable").append('<li class="ui-state-default"><img src="" width="100" height="100" /> <input type="text" value="textt" name="user-media-link[]"><input type="hidden" name="social-media-type" value="1"></li>');
}
它工作得很好,但我无法在输入中输入任何内容。我只能通过 TAB 按钮联系他们。当我点击它们时,什么也没有发生。您可以查看实时示例。
我阅读了与这个问题相关的所有问题,但我找不到正确的答案。
W3 Validation is OK There isn't any error on Firebug Operation System : Ubuntu 11.04 Browser : Firefox
I have a list which can be sortable. I'm using jQuery UI with widget, mouse, position, sortable addons.
CSS:
#sortable{
width : 550px;
display: inline-block;
}
#sortable li, #add {
width : 550px;
margin : 5px;
padding : 5px;
height : 50px;
}
#sortable li img.social-icon, #sortable li img.drag-cursor {
width: 40px;
height : 40px;
float : left;
}
#sortable li img.social-icon {
margin-right : 5px;
}
#sortable li img.drag-cursor {
margin-left : 5px;
cursor : move;
}
#sortable li input {
height:40px;
width:450px;
line-height: 45px;
float:left;
}
#add {
cursor : pointer;
text-align: center;
line-height: 45px;
}
.ui-state-highlight { height: 50px; line-height: 50px; }
HTML:
<div id="dash-wrapper">
<ul id="sortable">
<li class="ui-state-default">
<img src="images/social/twitter.png" class="social-icon" />
<input type="text" value="textt" name="user-media-link[]" class="user-media-link">
<input type="hidden" name="social-media-type" value="1">
<img src="images/drag.png" class="drag-cursor">
</li>
<li class="ui-state-default">
<img src="images/social/facebook.png" class="social-icon" />
<input type="text" value="textt" name="user-media-link[]">
<input type="hidden" name="social-media-type" value="1">
<img src="images/drag.png" class="drag-cursor">
</li>
<li class="ui-state-default">
<img src="images/social/rss.png" class="social-icon" />
<input type="text" value="textt" name="user-media-link[]">
<input type="hidden" name="social-media-type" value="1">
<img src="images/drag.png" class="drag-cursor">
</li>
</ul>
<div class="ui-state-default" onCLick="addNewSocial(); return false;" id="add">ADD</div>
</div>
Script:
$(function() {
$("#sortable").sortable({
placeholder: "ui-state-highlight"
});
$("#sortable").disableSelection();
});
function addNewSocial() {
$("#sortable").append('<li class="ui-state-default"><img src="" width="100" height="100" /> <input type="text" value="textt" name="user-media-link[]"><input type="hidden" name="social-media-type" value="1"></li>');
}
It's working very well, but I can't type anything to inputs. I can reach them only via TAB button. When I click them, nothing happens. You can see a live example.
I was read all questions which related with this question, but i couldn't find right answer.
W3 Validation is OK There isn't any error on Firebug Operation System : Ubuntu 11.04 Browser : Firefox
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
发生这种情况是因为您有
$("#sortable").disableSelection();
。将其删除即可正常工作。http://jsfiddle.net/KbBnu/1/
This happens because you have
$("#sortable").disableSelection();
. Remove it and will work ok.http://jsfiddle.net/KbBnu/1/
如果想阻止文本选择但同时继续使用输入,您应该尝试此操作
If would like to prevent text selection but continue to use inputs at the same time, you should try this
只需执行以下操作:
并将
sortable_container_id
替换为所有“可排序”元素的容器的元素的 id。Just do:
and replace
sortable_container_id
with the id of the element that is the container of all "sortable" elements.