Hi,
Tell me please is the Chosen library used in some special way in HikaShop? When the Chosen library is disabled and a normal select element is used, the following code displays an alert every time the State changes:
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script>
if(window.Oby){
window.Oby.registerAjax(['checkoutBlockRefresh'], function(){
$('#data_address_1_1_address_state').change(function(){
var currentStateSelect = $("#data_address_1_1_address_state option:selected").text();
alert(currentStateSelect);
})
});
}
</script>
But when the Chosen library is enabled and is used, the following code displays nothing when the State changes:
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script>
if(window.Oby){
window.Oby.registerAjax(['checkoutBlockRefresh'], function(){
$("#data_address_1_1_address_state_chzn").chosen().change(function(){
var currentStateChosen = ($("#data_address_1_1_address_state_chzn").text());
alert(currentStateChosen);
});
});
}
</script>
Also I tried in window.Oby.registerAjax(, function():
$('#data_address_1_1_address_state_chzn').on('change', function() {
var currentStateChosen = ($("#data_address_1_1_address_state_chzn").text());
alert(currentStateChosen);
});
and
$('#data_address_1_1_address_state_chzn').change(function(){
var currentStateChosen = $("#data_address_1_1_address_state_chzn option:selected").text();
alert(currentStateChosen);
})
and
$('#data_address_1_1_address_state_chzn').change(function(){
var currentStateChosen = $("#data_address_1_1_address_state_chzn").text();
alert(currentStateChosen);
})
Perhaps there is a way to handle the Chosen select change event in HikaShop?