Customizing screen dimensions for a single page using jQuery mobile

I am currently facing an issue with adjusting the size of a specific page within my application.

Even though I am using

<meta name="viewport" content="user-scalable=no, initial-scale=1, maximum-scale=1, minimum-scale=1, width=device-width, target-densitydpi=device-dpi"/>

to set the "normal" size for all pages, I need to modify the width of one particular page due to its wider image display. However, when I attempt to adjust it using

<div date-role="page" id="organigram" style="min-width:1000px;">

or with CSS:

#organigram > .ui-page {
min-width: 1000px;
}

it affects the width of ALL pages until I navigate away from this specific one containing the larger image. Upon returning via the "Back" or "Home" button in the page header, all sizes revert back to normal (device-width) except for the page with the modified min-width. Unfortunately, this is not suitable for my requirements. I have tried altering the image's width directly within the page, but this has no effect at all. Any suggestions or additional code needed, please let me know. Thank you!

/edit: I managed to find a temporary solution using JavaScript. Once the page loads, my script replaces the entire content of the page by

document.getElementById('organigram').innerHTML = myPageContent;

Nevertheless, this is not an ideal long-term fix.

Answer №1

One issue with jQuery Mobile pages is that adjusting the dimensions of one page will affect all other pages, which can be expected as they need to fit within a viewport.

To address this, you can modify the width of a page only when it is active by utilizing jQuery Mobile page events:

#targetPage refers to the specific page you want to adjust.

$(document).on('pagebeforeshow', '#targetPage', function(){       
    $(this).width(800);
});

$(document).on('pagebeforehide', '#targetPage', function(){       
    //Reset page width to its original size
});

If you are unfamiliar with jQuery Mobile page events, consider checking out my related answer for more insights: Exploring jQuery Mobile: Understanding Document Ready vs Page Events

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 flex box structure crumbles, causing the boxes to align side by side instead of in a masonry layout

I'm currently facing a challenge with my project regarding the utilization of flexbox. Everything seems to be in order, but as you resize your viewport to around 1400px, the column layout collapses. I'm looking for a way to prevent this from hap ...

Learn the process of updating Datatables' multiple column headers in real-time using ajax and jquery, all without the need to refresh

My goal is to dynamically change the column number and header of a table based on the return value of an AJAX call in conjunction with DataTables jQuery plugin. Below is the JavaScript and jQuery code I am currently using: $( document ).ready(function() { ...

Bootstrap - the input group button is designed to align to the right side

Currently, I am in the process of constructing a navigation bar for a website that includes a search bar and a grouped button. Everything functions properly when viewed on a desktop, but as soon as I switch to mobile view and the collapsible menu is activa ...

Submit the form without displaying any output in the browser, not even in the view source code

I have a basic form that needs to be submitted multiple times, but I want the submission process to be hidden from the browser. Simply using "hidden" or "display:none" won't completely hide the form code when viewing the page source. I tried using PHP ...

When making a POST request using formData through AJAX, the $_POST variable remains empty

Below is the form: <form id="complaintForm" enctype="multipart/form-data" method="POST"> <input type="number" id="isComplaintForm" value="1" hidden> <label for="fname&q ...

Gradually reveal each individual path of the SVG, one by one

I am faced with an SVG containing numerous paths like the following: <svg version="1.1" id="svg2" inkscape:version="0.91 r13725" sodipodi:docname="drawing.svg" xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd" xmlns:svg="http://w ...

Is it possible to load JavaScript code once the entire page has finished loading?

My webpage includes a script loading an external JavaScript file and initiating an Ajax query. However, the browser seems to be waiting for example.com during the initial page load, indicating that this external dependency may be causing a delay. Is there ...

Struggling to achieve proper alignment for a series of div tags

I have implemented a code block to read in an image pixel by pixel and display it as a series of div tags arranged in a table-like fashion. The code is mostly inspired by a comment on PHP.net (http://www.php.net/manual/en/function.imagecolorat.php). This i ...

Investigating the variety of HTTP 206 responses pertaining to video content

Currently, I am utilizing Amazon CloudFront to serve HTML5 videos. These videos are being requested through HTTP range requests and the expected responses are often in the form of HTTP 206 Partial Content. I have a requirement where I want to log the requ ...

What is the best way to ensure that the output responds to the function?

I have a total value output that needs to decrease when a checkbox is unchecked. The current function I have for unchecking the box is not working as expected. Jquery Total value calculation: $(document).ready(function() { var initialTotal = 720; $(" ...

Decoding JSON data

How do I parse 2 JSON objects? When AJAX returns just one object, it appears correctly: Object {32 : "Joseph"} However, when it returns more than 2 objects, this is what I get: ResponseText: "{"users":{"32":"Joseph"}}{"users":{"48":"Joseph K."}}" I h ...

Storing information in a table before having an assigned ID

Currently, I am developing a CMS using Codeigniter which consists of standard fields like title and post content, similar to Wordpress. On my page, there is an image uploader that utilizes ajax to save images to a MySQL table with basic fields including i ...

What is the best way to locate the final text node within the <p> element?

Looking at the code below, my goal is to identify and retrieve the text node that serves as the last child element. <p class="western" style="margin-bottom: 0.14in"> <font color="#000000"> <font face="Arial, serif"> <font ...

What is the best way to target the nth-child() of a slotted element within a web component that utilizes multiple uniquely named slots?

I am struggling to select the second slotted item in a specific slot using slot[name=foo]::slotted(:nth-child(2)){, but it's not behaving as I anticipated. Even though the first foo slot is styled with green, the second one doesn't follow suit. ...

What could be causing this highchart plot to fail to display in both IE and Chrome?

Check out the plot in this jsfiddle: http://jsfiddle.net/essennsee/y5HCm/ The plot looks good in Firefox, but only shows the legend in IE and Chrome. If I remove the following code snippet it works fine. Is there a different way to format the labels?: ...

CSS background image referencing in React to the public folder's path

I am currently working on a project using Create-React-App and I am trying to set a background image for my header section. Here is how I'm attempting to do it: background-image: url('~/Screenshot_11.png'); However, I encountered an error w ...

Spaces ahead and beneath the text

I'm struggling to style a small block of text within its element perfectly. Despite my efforts, there always seems to be unnecessary space in front and below the words. One workaround I found was adjusting the line height to remove the bottom gap, but ...

jQuery: Locate and eliminate any images in the text that appear after a specific group of tags if no images are present

Currently, I am in the process of developing a feed reader specifically designed to parse the Google News Feed. You can view and test the code on this Fiddle. My main challenge lies in removing titles and sources from the descriptions. Through my explorati ...

Prevent the Append button from being clicked when a duplicate entry is detected in jQuery

Hi there! I'm currently in the process of learning jQuery coding. Could anyone advise me on how to disable an entry or trigger an alert if it duplicates another APPENDED row? Below is the script I use for appending rows: var rowCount = 1; $('# ...

Is your data coming in as NaN?

I am currently developing a basic webpage that has the capability to calculate your stake and determine your return, reminiscent of a traditional betting shop. As of now, I have successfully hard coded the odds into my page. However, while testing my code ...