|
1 | 1 | <?php |
| 2 | + |
| 3 | +# @Copyright 2017 Rafal Marguzewicz pceuropa.net |
| 4 | + |
2 | 5 | pceuropa\sort\SortAsset::register($this); |
3 | 6 | use yii\helpers\Html; |
4 | 7 | use yii\helpers\Url; |
5 | 8 |
|
6 | 9 | $return = ''; |
7 | 10 | $el = ''; |
8 | 11 |
|
9 | | -foreach ($list as $item){ |
10 | 12 |
|
11 | | - if ($item['image'] != null){ |
12 | | - $el = Html::img( $config['image_url'] .$item['image'], ['class' => 'img-responsive', 'alt' => $item['name']]); |
| 13 | +#print_r($items);die(); |
| 14 | +# |
| 15 | +foreach ($items as $item){ |
| 16 | + if (isset($item['image_name']) ){ |
| 17 | + |
| 18 | + $el = Html::img( $config['image_url'] .$item['image_name'], ['class' => 'img-responsive', 'alt' => isset($item['image_name']) ? $item['image_name'] : '']); |
13 | 19 | } else { |
14 | | - $el = Html::a ( $item['name'], $item['url'] ); |
| 20 | + $el = Html::a ( $item['title'], $item['url'] ); |
15 | 21 | } |
16 | 22 |
|
17 | 23 | $row = '<div class="row"> |
|
44 | 50 |
|
45 | 51 | $this->registerJs('var config = { |
46 | 52 | group: "pclista", |
47 | | - animation: 0, |
48 | 53 | ghostClass: "ghost", |
49 | 54 | onUpdate: function () { |
50 | | - var a = []; |
51 | | - |
52 | | - $("#lista li").each(function (){ a.push($(this)[0].id) }) |
| 55 | + var a = [], data = {}; |
53 | 56 | |
| 57 | + $("#lista li").each(function (){ a.push($(this)[0].id) }); |
| 58 | + data = { serialize: true, array: a }; |
| 59 | + |
54 | 60 | $.ajax({ |
55 | | - url: document.URL, |
| 61 | + url: '.$config["controller"].', |
56 | 62 | type: "post", |
57 | 63 | dataType:"JSON", |
58 | | - data: { serialize: true, array: a }, |
59 | | - success: function (r) { |
60 | | - if (r.success === false) {console.log(r.message);} |
| 64 | + data: data, |
| 65 | + success: function (response) { |
| 66 | + if (response.success === false) {console.log(response);} |
| 67 | + if (response.success === true) { |
| 68 | + $("#message_request").text(JSON.stringify(data, null, 4)); |
| 69 | + $("#message_response").text(JSON.stringify(response, null, 4)); |
| 70 | + console.log(response);} |
61 | 71 | }, |
62 | 72 | error: function (XMLHttpRequest, textStatus, errorThrown) { |
63 | 73 | alert(textStatus); |
|
0 commit comments