0
我有這樣的jsfiddle:http://jsfiddle.net/VebTY/jQuery的日期選擇器掛起當輸入字段重新點擊(鉻)
它看起來這這僅僅是瀏覽器的問題。
當您單擊頁面中的某個項目時,它會添加一個文本字段,然後彈出一個日期選擇器。當你點擊文本框,然後回到文本框瀏覽器掛起5到10秒鐘。爲什麼它這樣做,我該如何解決它?
這裏是我的相關代碼:
$(document).on("focus", "td input[type=text]", function(e) {
e.stopPropagation();
if ($(this).closest("td").attr("data-type") === "date") {
var dt = $(this).val();
$(this).not(".hasDatePicker").datepicker();
$(this).datepicker("setDate", dt);
}
});
$(".editable").click(function(e) {
if (!$(e.target).is('input, textarea')) {
$(".editable").each(function() {
if ($(this).has("input")) {
var v = $(this).children("input.input, textarea").attr("data-orig");
$(this).text(v);
}
});
var type = $(this).attr("data-type");
var val = $(this).text();
if (type === "text" || type === "date") {
str = '<input type="text" data-orig="' + val + '" onfocus="this.value = this.value;" class="input" style="width: 100%;" value="' + val + '" /><br />';
} else if (type === "textarea") {
str = '<textarea class="input" data-orig="' + val + '" onfocus="this.value = this.value;" style="width: 100%;">' + val + '</textarea><br />';
}
str += '<input type="button" class="save-edit" value="Save" />';
str += '<input type="button" class="cancel-edit" value="Cancel" />';
$(this).html(str);
$(this).find("input[type=text], textarea").focus();
}
});
謝謝!這解決了問題! –
不客氣,祝你好運! – rusln