Created
September 8, 2015 07:42
-
-
Save mazjs/3b6191b651485916a071 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| //the whole thing is wrapped in an anonymous function | |
| $(document).on('change', '#id_tel_no', function() { | |
| var tel_no = $('#id_tel_no').val(); | |
| var state_code = $('select[name=state_code]').val(); | |
| var customer_id = '<?php echo $customer->id;?>'; | |
| if (state_code != '' && tel_no != '') { | |
| $.ajax({ | |
| type:"POST", | |
| timeout:AJAX_TIMEOUT, | |
| async: false, | |
| data: {state_code: state_code, tel_no: tel_no, customer_id: customer_id}, | |
| url:"", //took out url for security reason | |
| success: function( data ) { | |
| if (data.result != null) { | |
| $('#id_tel_no').focus(); | |
| dialog('Warning', data.result, DIALOG_WIDTH_WARNING_MESSAGE); | |
| }else{ | |
| return true; | |
| } | |
| } | |
| }); | |
| } | |
| }); | |
| $("#id_customer_form").on('click', '#save', function(e) { | |
| e.preventDefault(); | |
| var company_name = $('input:text[name=company_name]').val(); | |
| var country_code = $('#id_country_code').val(); | |
| var excluded_company_name = $('#id_excluded_company_name').val(); | |
| var customer_id = '<?php echo $customer->id;?>'; | |
| var edit = <?php echo isset($edit) && $edit ? $edit : 'false'; ?>; | |
| unsaved = false; | |
| if( ! edit || ! company_name_unique) { | |
| $.ajax({ | |
| type:"POST", | |
| timeout:AJAX_TIMEOUT, | |
| async: false, | |
| data: {company_name: company_name, country_code: country_code, excluded_company_name: excluded_company_name, customer_id: customer_id}, | |
| url:"", //took out url for security reason | |
| success: function( data ) { | |
| if (data.success) { | |
| $('#id_customer_form').submit(); | |
| } else { | |
| company_name_unique = false; | |
| } | |
| } | |
| }); | |
| } else { | |
| $('#id_customer_form').submit(); | |
| } | |
| }); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment