2011-11-13 73 views
0

jquery mobile,表單元素複選框有問題。所以,我在.cs文件代碼:jquery mobile複選框和ASP .NET

email = Request.Form["Email"]; 
password = Request.Form["password"]; 
rememberMe = Request.Form["remember_me"].AsBool(); 

由於通常,這段代碼必須填寫變量表單數據,但jQuery Mobile的複選框的狀態不會使用「檢查」 HTML標記。 (http://jquerymobile.com/test/docs/forms/checkboxes/index.html

這只是像'ui-checkbox-off/ui-checkbox-on'這樣的標籤更改類。

那麼,是否有可能沒有大量的代碼來檢查由jquery mobile創建的複選框的狀態?

Thx。

+0

一個決定,可能是隱藏複選框,但它不是很好= \ – FSou1

+0

jQueryMobile文檔說,檢查狀態存儲在輸入[type = checkbox]中。如果你看一看,你會發現這是真的。但是,將事件綁定到此類輸入上的「更改」事件並不總是有效。 – Wytze

回答

0

也許你可以做這樣的事情?

<div data-role="fieldcontain" id="divCheckbox"> 
    <fieldset data-role="controlgroup"> 
     <legend>Agree to the terms:</legend> 
     <input type="checkbox" name="checkbox-1" id="checkbox-1" class="custom" /> 
     <label for="checkbox-1">I agree</label> 
    </fieldset> 
</div> 

JS

$("#divCheckbox").click(function() { 

    var checkbox = $(this).find("input[type='checkbox']"); 

    var label = $(this).find(".ui-checkbox-on"); 

    checkbox.prop("checked", label.length); 
}); 

不是100%肯定,但至少在DOM變化(見http://jsfiddle.net/rcSza/4/)否則,你可以做一個隱藏字段東西..