|
1 |
| -$(document).ready(function() { |
| 1 | +$(document).ready(function () { |
2 | 2 | $(".click_sorting").on('click', function () {
|
3 | 3 | var desc = $(this).data('desc');
|
4 | 4 | var field = $(this).data('field');
|
5 | 5 | // 此处如果desc为0则是正序排列,点击后改为逆序排列
|
6 | 6 | var search = '?order_by=' + (desc ? "" : "-") + field;
|
7 | 7 |
|
8 | 8 | var form_data_array = $("#listForm").serializeArray();
|
9 |
| - for(var i = 0; i < form_data_array.length; i++) { |
| 9 | + for (var i = 0; i < form_data_array.length; i++) { |
10 | 10 | var item = form_data_array[i];
|
11 |
| - if(item.name != 'order_by') { |
| 11 | + if (item.name != 'order_by') { |
12 | 12 | search += '&' + item.name + '=' + item.value;
|
13 | 13 | }
|
14 | 14 | }
|
15 | 15 |
|
16 | 16 |
|
17 | 17 | window.location = window.location.pathname + search;
|
18 | 18 | });
|
| 19 | + |
| 20 | + $(".confirm-to-href-btn").on('click', function () { |
| 21 | + var href = $(this).data('href'); |
| 22 | + console.log('start to confirm. href:', href); |
| 23 | + if (!href) { |
| 24 | + swal("To Coder!", "you need add data-href on your button!"); |
| 25 | + return false; |
| 26 | + } |
| 27 | + swal({ |
| 28 | + title: "Are you sure?", |
| 29 | + type: "warning", |
| 30 | + showCancelButton: true, |
| 31 | + confirmButtonClass: "btn-danger", |
| 32 | + confirmButtonText: "Yes", |
| 33 | + closeOnConfirm: false |
| 34 | + }, |
| 35 | + function () { |
| 36 | + console.log('confirmed!'); |
| 37 | + window.location = href; |
| 38 | + }); |
| 39 | + console.log('end to confirm'); |
| 40 | + return false; |
| 41 | + }); |
19 | 42 | });
|
0 commit comments