티스토리 뷰

프로그래밍/Jquery Mobile

JQuery Mobile Code Snippets 1

쇠주는참이슬 2012. 4. 9. 15:44

 I want to share with you some important codes that you may need during JQuery Mobile development.These codes has been tested on Alpha 4 version.

Beta 1 has been released before two days, Therefore I will test them in my current project and inform you of any changes : 

 Also check JQuery Mobile Code Snippets 2.
 
Show and hide back button in your Application

 

 $(document).bind("mobileinit"function () {
           $.mobile.page.prototype.options.addBackBtn = true;
       });
 
 

 

Customizing the back button text

$(document).bind("mobileinit"function () {
$.mobile.page.prototype.options.backBtnText = "previous";
});

 

 

 

Hide "Close button" for dialog programatically:

  $('[data-role=dialog]div[id="YourDiaogdivID"]').live('pagecreate'function (event) {
     $("a[data-icon='delete']").hide();
 
        });
 

Change Select option element index:

     var myselect = $("select#foo");
       myselect[0].selectedIndex = 0; //The new index
       myselect.selectmenu("refresh"); //uset this line of code after any updating on the select element 
 
 

 

Change Select optoin elemetn text value:

   $("select#foo").parent().contents().children('.ui-btn-text').text('Your Text Here');
 

 

Refreshing a checkbox

   $("select#foo").parent().contents().children('.ui-btn-text').text('Your Text Here');
 
 

 

Hide select option element

 $('#foo').parent().hide();

 

 

Hide and Show Page Loading Message :

Before Beta 2: 
$.mobile.pageLoading(); //Show
$.mobile.pageLoading(true); //hide
 
Beta 2+ : 
$.mobile.showPageLoadingMsg();         
$.mobile.hidePageLoadingMsg();        

 

 

overriding $.mobile.loadingMessage

 
$(document).bind("mobileinit"function () {
    $.mobile.loadingMessage = 'My Loading Message';
   
});
 

 

Hide and Show jQuery-Mobile-Themed-DatePicker 

  $(".ui-datepicker").hide();
  $(".ui-datepicker").show();

 

 

 

Build your Custom Loading Message :

          $('#CustomeLoadingMessage').hide();//Hide the div 
 
 
            $('# CustomeLoadingMessage').ajaxStart(function () {
                $(this).show();
            });
 
            $('# CustomeLoadingMessage').ajaxStop(function () {
                $(this).hide();
            });

 

I will publish other important codes soon.

Hope that helps. 


출처 : http://weblogs.asp.net/yousefjadallah/archive/2011/08/09/jquery-mobile-code-snippets-1.aspx

댓글
공지사항
최근에 올라온 글
최근에 달린 댓글
Total
Today
Yesterday
«   2024/12   »
1 2 3 4 5 6 7
8 9 10 11 12 13 14
15 16 17 18 19 20 21
22 23 24 25 26 27 28
29 30 31
글 보관함