JQuery Mobile Code Snippets 1
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.