从下面a
我需要使用jQuery从属性中获取值data-autocomplete
(我们在那里有标签和值,但我只需要收集值),请帮助。
<a href="nullAUS%7C6214051%7C0HOAUSAQjdBwAAAAAIAwEAAAAA2igAgAAAAAAAAABkAAAAAP....8AAAAAAAAAAABub3J0AA--" data-transition="fade" data-autocomplete="{"label":"North Chigwell Primary, 115 Allunga Road, CHIGWELL TAS 7011","value":"AUS|6214051|0HOAUSAQjdBwAAAAAIAwEAAAAA2igAgAAAAAAAAABkAAAAAP....8AAAAAAAAAAABub3J0AA--"}" class="ui-link-inherit">North Chigwell Primary, 115 Allunga Road, CHIGWELL TAS 7011</a>
这是我正在尝试的代码:
callback: function (e) {
var a = $(e.currentTarget); // access the selected item
var address = $.trim(a.text());
// data-autocomplete
var moniker = $(a).attr("data-autocomplete");
$('#addressQas').val(address);
//$.ajax({
new FancyAjaxinator().jsonPost({
url: "/address/selectLine",
//dataType: "json",
data: {
"moniker": moniker,
"address": address
},
success: function (data) {
//console.log(data.responseObject);
var qasAddress = data.responseObject;
$('#address-line1').val(qasAddress.addressLine1);
if (qasAddress.state) {
$('#address-line2').val(qasAddress.addressLine2);
$('#address-townCity').val(qasAddress.suburb);
$('#address-state').val(qasAddress.state);
$('#address-state').parent().find('span.ui-selectmenu-text').text($("#address-state option[value=" + qasAddress.state + "]").text());
$('#address-postcode').val(qasAddress.postcode);
$('#address-line1').valid();
$('#address-townCity').valid();
$('#address-state').valid();
$('#address-postcode').valid();
}
$('#QASaddressField').hide();
$('.qasAddressFields').show();
//setFocus();
}
});
this.close;
return false;
}