The CSS isn't loading when using $.mobile.changePage

I am facing a strange issue with ajax in my login page. The login page calls the main page using ajax, as shown below:

 // Function to call WCF  Service - Infrastructure       
    function CallService() {
        $.ajax({
            type: Type, //GET or POST or PUT or DELETE verb
            url: Url, // Location of the service
            data: Data, //Data sent to server
            contentType: ContentType, // content type sent to server
            dataType: DataType, //Expected data format from server
            processdata: ProcessData, //True or False
            success: function (msg) {//On Successfull service call
                ServiceSucceeded(msg);
            },
            error: ServiceFailed// When Service call fails
        });
    }

    function ServiceSucceeded(result) {

        if (DataType == "json") {
            var resultText = result;
            if (resultText.result == "True") {
                $.mobile.changePage("MainMenu.aspx",{ transition: "slideup" });
            }
            else {
                //Show Error Message
            }
        }
    }

In each page, I have included a reference to a js file called "general.js" which contains the following code:

function processMenu(menuOptions) {
var options = menuOptions.split('');
var currentOptions = '1234567'.split('')

for (i = 0; i < currentOptions.length; i++) {
    var index = (i + 1) + '';
    if (options.indexOf(index) < 0) {
        var op = $('#op' + currentOptions[i]);
        op.attr('disabled', true);
        op.addClass('btndisabled');
        $(op).live("click", function (event) {
            //do stuff
            event.preventDefault(); // Prevent default link behaviour
        });
    }
}

This code checks some numbered controls and enables a CSS class called "btndisabled" when necessary.

The CSS for "btndisabled" is:

.btndisabled{    
    background-color: rgb(236,233,216);
    color: #CCC;
    font-style: normal;
}

The issue arises when I use:

$.mobile.changePage("MainMenu.aspx?",{ transition: "slideup" });

The contents of Login.aspx change to MainMenu.aspx but the JS code:

op.attr('disabled', true);
op.addClass('btndisabled');
$(op).live("click", function (event) {
    //do stuff
    event.preventDefault(); // Prevent default link behaviour
});

gets executed without applying the CSS. I'm not sure what's wrong. Any ideas on how to resolve this?

UPDATE

Upon observing the behavior of the object on postback and during the ajax call, I noticed something interesting but puzzling.

During Postback

Check the HTMLAnchorElement

Ajax

If the DOM has not loaded the anchor object, HOW IS POSSIBLE TO ASSIGN THE event.preventDefault()???

This seems quite perplexing...

Answer №1

The solution you seek can likely be found on the official jQuery Mobile forum:

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

The menu bar displays navigation options that are not aligned on the same level

I have been trying to align the navigation links on the same line, but unfortunately, I have not been successful. I have made several attempts but would appreciate any guidance or hints you can provide. Thank you in advance for your help! If necessary, I ...

Limiting the number of Facebook friends in response to a specific need

Is there a way to fetch only 5 friends of a logged in user instead of the entire list? FB.getLoginStatus(function(response) { if (response.status === 'connected') { FB.api('/me/friends', {fields: 'name,id,location,birthday&a ...

The addition of a slash between the hashtag and the anchor name by Fullpage.js is causing conflicts with ng-include

My experience with using fullpage.js on a simple site alongside angular directives has been met with an issue. When including a .phtml file, the anchor functionality of fullpage.js stops working as it adds a slash before and after the anchor name. UPDATE ...

Is it possible to save CF7 form submissions as PHP variables for front-end use?

Seeking assistance as I've encountered a roadblock and have been searching for a solution for the past 5 hours. I've set up my CF7 form and implemented a function to store all fields as variables and display them in the error log, which is funct ...

Adjust the size of a div container depending on the content it holds

If the element div.PageheaderDescription does not contain any img or div#cat-text, I'd like the height to be set to 0px to eliminate any white space. Below is my CSS code: .PageHeaderDescription { height: 320px; position: relative; width ...

Change the body selector in CssResource to apply custom styles

I have implemented a CssResource within a ClientBundle following the guidelines provided in the documentation at this link. To access the styles from my UiBinder xml, I have used ui:with as explained in the documentation available at this guide. While th ...

I am looking to modify the visibility of certain select options contingent upon the value within another input field by utilizing ngIf in AngularJS

I am currently utilizing Angularjs 1.x to develop a form with two select fields. Depending on the option selected in the first select, I aim to dynamically show or hide certain options in the second select field. Below is the code snippet for the form: &l ...

Tips on displaying a div for a brief moment and then concealing it

Is it possible to create a div that will disappear after 10 seconds of the page loading using PHP or JavaScript? Here is an example of the code: <html> <head></head> <body> <div class="LOADING" id="LOADING" name="LOADING">&l ...

Mastering Theme Transformation with SASS

My website is constructed using SASS, and I am facing an issue where the variables I set for light and dark themes are not changing as expected. Whenever I switch between themes, all variables revert to their original values, making it difficult for me to ...

Error: Unable to encode data into JSON format encountered while using Firebase serverless functions

I am currently working on deploying an API for my application. However, when using the following code snippet, I encountered an unhandled error stating "Error: Data cannot be encoded in JSON." const functions = require("firebase-functions"); const axios = ...

Patiently anticipating the completion of a jQuery animation

I am currently working on some jQuery code that handles toggling containers and buttons. The specific snippet of code I am focused on is the following: var id = $(this).data('id'); if ($('#container').is(':visible')) { $( ...

CSS-exclusive dropdown menu elements peeking out

I have been working on a CSS-only drop-down menu and I am encountering an issue where other content seems to be showing through. Despite my efforts, I can't figure out why this is happening. If you would like to take a look, here is the link: http:// ...

Tips for creating an onChange function in an input field using jQuery

I am looking to dynamically create inputs where each input has an `onChange` function with a variable. Here is my code: var distinct_inputs = 0; $('.icon1').click( function(){ distinct_inputs = distinct_inputs + 1 ; $('#insert-file&apo ...

The asp.net ajax client-side framework was unable to load properly

Does anyone know how to address this specific error? The asp.net ajax client side framework was not able to load properly I am currently working with Vb.net and attempting to utilize the timer control feature. ...

Tips on arranging elements so that they appear in the same row as other similar elements

Currently, my display looks like this. The add to cart button is not showing up in a row because the product name of the third element is a bit lengthy. This is the code used to display the products: <div> <div class='box' ng-repe ...

The font size escalates following the activation of a Java alert box on an ASPX webpage

Recently, I came across an interesting solution to a problem with a PHP application. It was discovered that placing the Java Script in the body section resolved the issue where CSS file attributes were being ignored when clicking the Alert box. In my code ...

Exploring Typescript for Efficient Data Fetching

My main objective is to develop an application that can retrieve relevant data from a mySQL database, parse it properly, and display it on the page. To achieve this, I am leveraging Typescript and React. Here is a breakdown of the issue with the code: I h ...

Issues with the transparency of a basic tab image gallery (CSS + jQuery)

My tab image gallery project is nearly complete, but I'm facing some challenges with the styling. The default thumbnail doesn't load with maximum opacity as intended and my jQuery code seems to be interfering with the hover effect of my CSS. I di ...

Is your $http request causing an XML parsing issue?

I'm attempting to utilize the $HTTP method from angularJS to access my restful web service. On entering my web service URL in the browser, I receive a result of APPLICATION/JSON type. {"id":20418,"content":"Hello, World!"} The URL for my web servic ...

Having issues with -ms-filter not functioning in IE while using Angular 4

Having trouble with filters not functioning in IE browser when using angular 4. Below is the CSS code snippet: .style{-ms-filter: grayscale(50%); -ms-filter: brightness(70%);} ...