我對錶單字段使用jqtransform。當我將動態字段添加到表單時,jqtransform不適用於新字段。 請參閱samplecode,jqtranform不適用於動態添加的字段
$(function(){
$('form#js_greatdeals_form').jqTransform();
$('#js_greatdeals_form div.jqTransformSelectWrapper ul li a').click(function(){
var value = $(this).parent().index();
$("#select_cntry").attr('selectedIndex', value);
var countryiso = $("#select_cntry").val();
if(countryiso == 1) {
var content = '<select name="state" id="state"><option value="s1">State1</option><option value="s2">State2</option></select>';
$('#newselect').html(content);
$('select#state').jqTransform(); //Newly added
}
});
});
我的形式是,
<form id="js_greatdeals_form" name="js_greatdeals_form" method="post">
<select id="select_cntry">
<option selected="selected">select</option>
<option value="1">Country1</option>
<option value="2">Country2</option>
</select>
<div id="newselect"></div>
</form>
我試過了question給出的答案[請參見注釋行「新增」。但是這個解決方案對我來說也不起作用。 請做必要的。由於
我也有類似的問題,這裏是一個答案爲我工作:http://stackoverflow.com/questions/8900367/jqtransform-select-ajax-update/9392412 [1]:http://stackoverflow.com/questions/8900367/jqtransform-select-ajax -update/9392412 – Vincent