Commits

Tino de Bruijn  committed 0d8ab58

Clear forms and go back on saving data

  • Participants
  • Parent commits a9ab9c8

Comments (0)

Files changed (1)

File js/script.js

     
     ////////////////
     // Setup buttons
-    //
+
     $('#reload-feeds').live('click', function() {
         var api_key = $.storage.get('api_key');
         var user_id = $.storage.get('user_id');
         var user_id = $('#user_id')[0].value;
         $.storage.set('api_key', api_key);
         $.storage.set('user_id', user_id);
+        $.mobile.changePage('#main');
     })
     
     /////////////////////
             statusCode: {
                 200: function (data) {
                         alert('Data saved');
+                        form.find('input[type=text]').val('');
+                        history.back();
                         $.mobile.hidePageLoadingMsg();
                     },
                 401: function() {
                     alert('unauthorized');
+                    form.find('input[type=text]').val('');
+                    history.back();
                     $.mobile.hidePageLoadingMsg();
                 },
                 404: function() {
                     alert('404: not found');
+                    form.find('input[type=text]').val('');
+                    history.back();
                     $.mobile.hidePageLoadingMsg();
                 }
             },
                     ).appendTo('#container').page().trigger('pagecreate');
             }
         }
-        
     })
     
     //////////////////////
     // Setup of feed detail page
+    
     $('#container').on('click', 'a.view-feed', function () {
         if ($(this).attr('href').charAt(0) == '#') {
             if ($($(this).attr('href')).length == 0) {
         
     })
     
-    
-    
+    // Back on swipe
     // $('body').on('pagecreate', function (event) {
     //         $('div[data-role=page]').live("swiperight", function () {
     //             var prevpage = $(this).prev('div[data-role="page"]');
     //         });
     //     });
     
+    
     ////////////////////////
     // Lets try with touchOverflow
+    
     $(document).bind("mobileinit", function(){
       $.mobile.touchOverflowEnabled = true;
     });