jquery UI datepicker不能动态插入输入 [英] jquery UI datepicker not working on dynamically inserted input
本文介绍了jquery UI datepicker不能动态插入输入的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我将输入字段动态添加到 td
元素
I am adding input field dynamically to a td
element
$('.edit_text').live('click',function(){
$(this).html('<input type="text" value="'+$(this).text()+'" style="background:url(text_bx.gif) no-repeat bottom;display:inline;padding: 0; margin: 0;" class="editing" >');
$(this).children('input').focus();
if ($(this).attr('id')=='date'){
$(this).children('input').datepicker( "refresh");//"option", "dateFormat","yy-mm-dd");
}
});
但是如果td有id日期,则datepicker不显示。
我也有插入输入字段的模糊功能,这是一个问题吗?
But if td has id date, datepicker is not showing up. I also have blur function on inserted input field, is that a problem?
$('.editing').live('blur',function(){
//did something
});
推荐答案
嗯,下面是动态 jquery date picker
与可编辑的文本框,您可以相应地更新代码。
Well, Below is the dynamic jquery date picker
with editable textbox you can update the code accordingly.
$(function(){
$('#thedate').datepicker({
dateFormat: 'dd-mm-yy',
onSelect: function(dateText) {
$('#dateContainer').text(dateText);
console.log(dateText);
}
});
});
<link href="http://code.jquery.com/ui/1.8.21/themes/base/jquery-ui.css" rel="stylesheet"/>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script>
<script src="http://code.jquery.com/ui/1.8.18/jquery-ui.min.js"></script>
Shown Date : <div id="dateContainer" type="button" > currentData </div>
<input id="thedate" type="text" /><br />
<input id="thesubmit" type="button" value="Submit" />
JS小提琴与日期选择器: -
http://jsfiddle.net/vikash2402/8w8v9/1989 /
JS Fiddle with date picker and div: -
http://jsfiddle.net/vikash2402/8w8v9/1990/
希望这将有助于您:)
Hoping this will help you :)
这篇关于jquery UI datepicker不能动态插入输入的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文