function function init_first_radio input name delivery first prop chec

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
$(function() {
function init_first_radio(){
$('input[name=delivery]:first').prop('checked', true).change();
$('input[name=payment]:first').prop('checked', true).change();
};
{% if request.method == 'GET' %}
init_first_radio();
{% endif %}
// change city
(function(){
var city = $("#id_city");
var delivery = $("#delivery-ajax-wrap");
var payment = $("#payment-ajax-wrap");
var issue = $("#issue-ajax-wrap");
var issue_block = $("#issue-block");
var info_block = $("#info-block");
function change_delivery(){
var lis = $('ul#id_delivery li');
issue_block.hide();
info_block.show();
lis.on('change', function(){
var delivery_id = $(this).find('input').val();
if(delivery_id == '3') {
issue_block.show();
info_block.hide();
} else {
issue_block.hide();
info_block.show();
}
});
}
city.change(function(){
var city_id = $(this).val();
$.ajax({
url: '/order/ajax_city/' + city_id + '/',
dataType: 'json'
}).done(function(data) {
delivery.html(data['delivery_widget']);
payment.html(data['payment_widget']);
issue.html(data['issue_widget']);
change_delivery();
init_first_radio();
});
});
change_delivery();
})();
});