2013-04-10 125 views
0

現狀:jQuery的顯示和隱藏,使用複選框狀態

我有一個UL列出一堆人 我在上面「所有」和「共同」

在負載你看到所有兩個按鈕的人。然後,您可以單擊「通用」按鈕,僅對特定人員過濾UL。

這工作正常。但在每個LI中,我有2個複選框 - 當我在全部類別中選中它們,然後選擇最近的選項卡來檢查其他人,然後返回到全部選項卡時,有時會丟失複選框狀態。

應當指出的是,這正與PhoneGap的開發

function getFriends(common) 
{ 

if(common=="common") 
{ 
    //Hide everyone to start with 
    $("#PersonSelection li").hide(); 
    //ajax query that loops through the common players goes here 
    $('#'+item.PlayerId).show(); //this is the id of each li that is common, so after I hide all I just show those that are common 
    //end ajax loop 
} else { 
    if ($("#PersonSelection li").size() > 1) //this is there for when we go from common back to all I don't have to go back to the DB 
    { 
    $("#PersonSelection li").show(); 
    } 
    else 
    { 
    //go back to ajax query that loops a variable with li and checkbox info and the appends 
    document.getElementById('PersonSelection').innerHTML += people; 
    } 
} 
+0

爲了讓您得到更有幫助的答案,您應該提供一個html和javascript樣本。可能通過jsfiddle。 – scottmgerstl 2013-04-10 18:23:10

+0

這個問題似乎與'people'的價值有關。它不包括對複選框狀態的更新。爲什麼'All'按鈕不能顯示所有的'LI's重建整個列表? – Barmar 2013-04-10 18:29:24

+0

你的問題也令人困惑。在開始時你提到「所有」與「常見」,但問題描述是指「所有」與「最近」。 – Barmar 2013-04-10 18:31:01

回答

0

好吧,我想通了 - 我想我已經調試不錯,但它並出具本的document.getElementById(「PersonSelection」 ).innerHTML + = people;