2011-11-27 57 views
2

如果有人經歷了jPicker,我真的想一些這方面的幫助。我有一個jPicker輸入框的形式,當我發佈使用Ajax的形式,我嘗試的形式重置回它的原始值。除了我不知道如何將jPicker盒子重置爲初始狀態,有人知道如何做到這一點嗎?jQuery的jPicker重置完全

回答

4

jPicker$.jPicker.List[]陣列中維護其控制信息。要刪除你需要摧毀$.jPicker.List[]陣列中的相應條目中的控制jPicker關聯。

遍歷數組中的項找到引用與

$.jPicker.List[index].id 

控制當你發現在數組中你控制一個列表,與

$.jPicker.List[index].destroy() 

破壞後摧毀它數組元素,您將需要刪除與該控件關聯的SPAN jPicker html對象。如果只有一個你可以

$('span.jPicker').remove() 

否則你將需要找到特定HTML元素

$(rowParent).find('span.jPicker').remove(); 

可選:如果您使用的類的引用與ID參考,使用。數據()函數標記您的控件並使用以下語句檢索唯一值

$($.jPicker.List[index]).data() 
0

你可以嘗試從元素解除綁定jPicker,然後你又要重新設置後重新綁定,應使其恢復到默認設置。

+0

我試過了,但jPicker增加噸元素和風格的一切,所以我只是想弄清楚如何做到這一點,而無需編寫代碼來做到這一點。但嚴重的是,jPicker並沒有自己的方式來做到這一點? –

+0

不是我從文檔中看到的 –

0

如上所述,您可以嘗試使用som像這樣:

var id =$.jPicker.List[i].id; //getting the id of the element you've binded jpicker with 
$.jPicker.List[i].destroy(); //destroying the instance in the jPicker List 
$("#"+id).parent().find('span.jPicker').remove(); // destroying the span containing the graphical jPicker 
$("#"+id).jPicker(); // And finally reinstancing the jPicker instance on your element 

它應該讓你的選擇器閃爍(刪除然後重新創建)。