/
ria.client.js
78 lines (65 loc) · 2.51 KB
/
ria.client.js
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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
/**
* Created with JetBrains PhpStorm.
* User: amalyuhin
* Date: 01.07.13
* Time: 13:40
* To change this template use File | Settings | File Templates.
*/
$(function(){
updateAutoNumeric();
updateFormFields();
$("#create_client_form_id").ajaxForm({
method: 'post',
dataType: 'html',
beforeSubmit: function(arr, form, options) {
$(".form-actions .btn").hide();
$(".form-actions .progress").show();
},
success: function(response){
$(".create-client-form").html(response);
}
});
//TODO check in IE /ria/client/create
$(document).on('change',"#wealthbot_riabundle_riacreateclienttype_profile_model", function(event){
$('#wealthbot_riabundle_riacreateclienttype_profile_suggested_portfolio').attr('disabled', 'disabled');
var form = $(this).closest('form');
var model_id = $(this).val();
$.ajax({
url: form.attr('data-complete-models-url'),
data: { model_id: model_id },
success: function(data) {
$("#wealthbot_riabundle_riacreateclienttype_profile_suggested_portfolio").html(data.options);
},
complete: function() {
$('#wealthbot_riabundle_riacreateclienttype_profile_suggested_portfolio').attr('disabled', false);
}
});
});
// Event for button Apply
$(document).on('click',"#save_client_btn_id", function(event){
var options = {
dataType: 'json',
type: 'POST',
success: function (response) {
$('.create-prospect-content').replaceWith(response.content);
$("html, body").animate({ scrollTop: 0 }, "slow");
}
};
$("#create_client_form_id").ajaxSubmit(options);
event.preventDefault();
});
$(document).on('change','#ria_client_account_account_type', function (event) {
checkSelectedAccountType(accountTypes, '#ria_client_account_account_type');
});
});
function updateFormFields() {
var form = $('#create_client_form_id');
if (form.hasClass('create-continue-form')) {
var hasRetirementAccount = form.attr('data-retirement-accounts');
var accountTypes = JSON.parse(form.attr('data-account-types'));
if (hasRetirementAccount) {
$('#current_employer_retirement_plan_1').attr('checked', true);
}
checkSelectedAccountType(accountTypes, '#wealthbot_userbundle_client_account_type_account_type');
}
}