我使用intlTelInput爲電話&移動領域在asp.net webform網站上。國際電話輸入與國家同步插件不工作
目前我使用它作爲一個基本的插件作爲展現在這個example
var input = $("#ContentPlaceHolder1_txtPhone"), output = $("#output");
var country = $("#ContentPlaceHolder1_ddCountry");
input.intlTelInput({
preferredCountries: ['ae'],
autoHideDialCode: true,
nationalMode: false,
utilsScript: "../../Scripts/phone/js/utils.js" // just for formatting/placeholders etc
});
我現在想將其與國家下拉同步,這樣,當用戶選擇的國家,那麼它會自動選擇電話字段&移動領域的網絡形式與國家在電話領域。
我試圖用這個例子,但它不工作要麼打破插件或者downt工作
http://intl-tel-input.com/node_modules/intl-tel-input/examples/gen/country-sync.html
代碼,我試圖
var countryData = $.fn.intlTelInput.getCountryData(),
telInput = $("#ContentPlaceHolder1_txtPhone"),
addressDropdown = $("#ContentPlaceHolder1_ddCountry");
// set it's initial value
//var initialCountry = telInput.intlTelInput("getSelectedCountryData").iso2;
//addressDropdown.val(initialCountry);
// listen to the telephone input for changes
telInput.on("countrychange", function (e, countryData) {
addressDropdown.val(countryData.iso2);
});
// listen to the address dropdown for changes
addressDropdown.change(function() {
telInput.intlTelInput("setCountry", $(this).val());
});
我有地方的代碼在codepen http://codepen.io/anon/pen/wgzppg上。
我不知道我在哪裏做錯了。我嘗試了幾件沒有任何運氣的東西。
我從國家下拉數據庫表的數據而不是插件的數據,以便可能導致問題的地方。但國家代碼也匹配。