Note that there are some explanatory texts on larger screens.

plurals
  1. POProper way to override a JQuery Mobile method in $.mobile
    primarykey
    data
    text
    <p>The JQuery Mobile app I'm working on tends to freak out when the soft keyboard launches. I've implemented a solution and it works great, but I had to edit jquery.mobile-1.2.0.js directly to do it. I'd much rather keep my changes in a jquery.mobile.customizations.js file, which extends jQuery Mobile.</p> <p>I tried to do the following with no success:</p> <pre class="lang-js prettyprint-override"><code>delete $.mobile.getScreenHeight; $.mobile.last_width = null; $.mobile.last_height = null; $.mobile.getScreenHeight = function() { // My modified version } </code></pre> <p>I added alert statements into my <code>$.mobile.getScreenHeight</code>, plus the original <code>$.mobile.getScreenHeight</code>. I did see my custom method's alert being fired, but on occasion, it would fire the alert in the original function as well.</p> <p>Does anyone know the proper way to override a method in $.mobile and also add two new properties?</p> <p>(Full details about the original issue are in <a href="https://stackoverflow.com/questions/12879857/window-resize-due-to-virtual-keyboard-causes-issues-with-jquery-mobile">window.resize due to virtual keyboard causes issues with jquery mobile</a>)</p> <p><strong>Update:</strong></p> <p>@elclanrs - I've tried to implement the code below with no luck. I've also tried swapping the second and third parameters. Whenever I run the code, it fires my extended getScreenHeight, but then it fires the base getScreenHeight. (I hollowed out the original getScreenHeight and put an alert inside. That alert should never fire.</p> <p>Open for thoughts!</p> <pre class="lang-js prettyprint-override"><code>$.mobile = $.extend( {}, $.mobile, { last_width: null, last_height: null, getScreenHeight: function() { // My code... } } ); </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload