Commit 0d08b06d 0d08b06ddcc4fb81098fa19ba78d2800e3cef689 by Adnan Ahmad

Update jquery.js

1 parent 61b78aa1
...@@ -101,7 +101,7 @@ $(document).ready(function(){ ...@@ -101,7 +101,7 @@ $(document).ready(function(){
101 SubItem = ""; 101 SubItem = "";
102 item += "</div>"; 102 item += "</div>";
103 } 103 }
104 $("#mainRightDiv").append(item); 104 $("#mainRightDiv").html(item);
105 } 105 }
106 106
107 //DisplayItems(); 107 //DisplayItems();
...@@ -120,6 +120,29 @@ $(document).ready(function(){ ...@@ -120,6 +120,29 @@ $(document).ready(function(){
120 DisplayItems(items); 120 DisplayItems(items);
121 }); 121 });
122 122
123 // Sort By Albums
124 // Ascending
125 $('body').on('click', '.AssItem',function () {
126
127 $(this).click(function(){
128 items.sort(function(a,b) {return (a.song > b.song) ? 1 : ((b.song > a.song) ? -1 : 0);} );
129 $("#mainRightDiv").empty();
130 DisplayItems(items);
131 });
132
133 });
134
135 // Descending
136 $('body').on('click', '.DessItem',function () {
137
138 $(this).click(function(){
139 items.sort(function(a,b) {return (a.song > b.song) ? -1 : ((b.song > a.song) ? 1 : 0);} );
140 $("#mainRightDiv").empty();
141 DisplayItems(items);
142 });
143
144 });
145
123 // Search By Singer Name 146 // Search By Singer Name
124 $("#SearchByArtistName").keyup(function(){ 147 $("#SearchByArtistName").keyup(function(){
125 SearchValue = $(this).val(); 148 SearchValue = $(this).val();
...@@ -180,9 +203,20 @@ $('#item_form').on('submit', function (e) { ...@@ -180,9 +203,20 @@ $('#item_form').on('submit', function (e) {
180 contentType: false, 203 contentType: false,
181 success: function (info) { 204 success: function (info) {
182 document.getElementById("item_form").reset(); 205 document.getElementById("item_form").reset();
206 $.ajax({
207 type:'GET',
208 url: '/Assignments/get.php',
209 success: function (data){
210 items = JSON.parse(data);
211 console.log('Second ajax');
212 DisplayItems(items);
213 }
214 });
183 alert(info); 215 alert(info);
216
184 } 217 }
185 }); 218 });
219
186 220
187 }); 221 });
188 // update items 222 // update items
...@@ -216,9 +250,19 @@ $('#item_form').on('submit', function (e) { ...@@ -216,9 +250,19 @@ $('#item_form').on('submit', function (e) {
216 url: '/Assignments/database.php', 250 url: '/Assignments/database.php',
217 data:{'id':id, 'action':action}, 251 data:{'id':id, 'action':action},
218 success: function (info){ 252 success: function (info){
253 $.ajax({
254 type:'GET',
255 url: '/Assignments/get.php',
256 success: function (data){
257 items = JSON.parse(data);
258 console.log('second ajax');
259 DisplayItems(items);
260 }
261 });
219 alert(info); 262 alert(info);
220 } 263 }
221 }); 264 });
265
222 } 266 }
223 267
224 268
......