2011-08-10 91 views
0

jQuery的生活跨度檢查了這一點請到http://offline.raileisure.com/不更新,直到第二次點擊

在右側的預訂部分,選擇站主人的房子,然後選擇在8月15日的日期進行檢查。然後中選擇4。天... ...

OK

現在回去,並選擇8月29日的不同日期。

4天應該取消,但直到你做了進一步點擊其他地方是不...

我想我需要被更新直播ATTR。但不確定。

到勾去掉#spanduration我使用:

$('input[name="duration"]').removeAttr('checked'); 
$("#spanduration").attr("style", "background-position: 0px 0px;"); 

,但它不工作,直到你這樣做第二次點擊任何地方。

+0

你使用jQuery UI的日期選擇器? – Rafay

回答

0

也許是因爲它是一個單選按鈕。

嘗試將其更改爲複選框?

單選按鈕不喜歡被選中,如果沒有其他檢查:

<input type="radio" value="0" name="duration"> 
<input type="radio" value="1" name="duration"> 
<input type="radio" value="2" name="duration"> 
<input type="radio" value="3" name="duration"> 

和獨立

<input type="radio" value="0" name="other_name"> 

在另一方面複選框取消選中對方:(註名是陣列等)

<input type="checkbox" value="0" name="duration[]"> 
<input type="checkbox" value="1" name="duration[]"> 
<input type="checkbox" value="2" name="duration[]"> 
<input type="checkbox" value="3" name="duration[]"> 

和獨立

<input type="checkbox" value="0" name="other_name"> 

你可以寫這樣的事情有一個獨立的複選框的能力,亦自單選按鈕的甜頭:http://jsfiddle.net/LJJrZ/

$(document).ready(function(){ 
    var selector = "input[type=checkbox]"; 
    $(selector).click(function(event){ 
     var checked = $(this).is(':checked'); 
     if (checked) { 
      $(selector).attr("checked", false); 
      $(this).attr("checked", true); 
     } 
    }); 
}); 
0

更改事件不會在文本輸入觸發,直到輸入模糊。

您可以嘗試在填充日期後手動模糊輸入(對於輔助功能來說不太好)。或者更好的是,在填充日期後手動觸發更改事件。例如

//... 
// After date is populated 
$('#date').trigger('change'); 
//... 

查看完整的例子在這裏:http://jsfiddle.net/irama/rJGpn/

編輯:看你的代碼,它看起來像有一個機會(當實例的日期選擇器)插入到一個回調函數如下:

$('#date').datepicker({ 
    // ... 
    onSelect: function (e) { 
     // ... 

     $('#date').trigger('change'); 
    } 
    // ... 

讓我們知道你是怎麼回事!

+0

嘿@李你怎麼樣?你能觸發這個變化嗎?讓我們知道你是否需要任何幫助。 – irama