網頁

2014年4月9日 星期三

jQuery Mobile Examples

Geolocation based List Sorting


While experimenting with jquery mobile and local storage the other day i came up with a very simple to do list app. All the tasks are saved in local storage and will remain there until they are deleted by the user.
View Demo (best experience on mobile device)
using-localstorage-to-store-json

Getting Checkbox Value Jquery Mobile

How to use local storage to retain checkbox states for filtering items


 

       var checkBox_html;

        $.each(localStorage, function(key, value) {  //key, value
          console.log(key + ': ' + value); 

             var obj = JSON.parse(localStorage.getItem(key));
        
               var checkBox_add_html =  (obj.checked == 'checked') ? 'checked="checked"' : "" ;
               checkBox_html = '';
               checkBox_html +=''; 
              $(checkBox_html).appendTo("fieldset");
              $("#first").trigger("create");
        });

 
      //change input events
      $( "input" ).change(function() {

         isChecked = $(this).prop( "checked" )?'checked':'not';

           localStorage.setItem(this.id, JSON.stringify({
                      name: $(this).prop( "name" ),
                      checked: isChecked
                  }));  

      }).change();

沒有留言:

張貼留言

注意:只有此網誌的成員可以留言。