代码中有隐藏的输入,默认情况下必须尝试,并使用下拉框更改。代码:html:
<div class="form-group">
<label class="col-sm-3 control-label">Fiyat</label>
<div class="col-sm-4 col-md-3 col-lg-2">
<div class="input-group input-group-sm">
<input type="text" placeholder="Fiyat" class="form-control js-listing-price js-numeric" name="price.amount" />
<div class="input-group-btn btn-default">
<button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown">
<span class="js-currency-preview">TL</span>
<span class="caret"></span>
</button>
<ul class="dropdown-menu pull-right">
<li><a data-value="TRY">TL</a></li>
<li><a data-value="USD">$</a></li>
<li><a data-value="EUR">€</a></li>
</ul>
<input type="hidden" value="TRY" class="js-listing-price-currency js-currency" name="price.currency">
</div>
</div><!-- /input-group -->
</div>
</div>
javaScript:
$('.dropdown-menu').on('click', 'li a', function(e) {
e.preventDefault();
$('.js-currency-preview').text($(this).text());
$('.js-listing-price-currency').val($(this).data('value'));
});
};
除此JS货币字段外,所有其他字段都在工作。
作为骨干粘合剂看不到隐藏输入中的隐藏变化,它们一定不能更改页面。可以通过将trigger('change');
添加到代码来解决:
$('.js-listing-price-currency').val($(this).data('value')).trigger('change');