Popup not center screen at the first click

Hi All,
I have just met an issue:
At a ViewProduct dialog, when click on the photo (the resized one) to show a popup which displays the full-size photo. I want center the popup on sceen (as in http://msdn.microsoft.com/en-us/library/jj733572.aspx#centerpopup).
The width & height of the photo in popup are "Fit to Content". At the first click, the popup's not centered. After closing the popup, from the second click in ViewProduct, the popup's centered correctly.
Hope you can help me. Thankyou.
My code:
myapp.ViewProduct.PhotoURL1_postRender = function (element, contentItem) {
// Write code here.
displayPhoto(element);
var img = $(element).find("img");
$(element).css({
'cursor': 'pointer'
$(element).prop('title', 'Click here to display full-size photo');
$(element).click(function () {
// Note:If using JQuery Mobile 1.3 (or higher) use
// "popupcreate" rather than "popupbeforeposition"
$(window).one("popupbeforeposition", function (e) {
$(e.target).popup({
positionTo: "window",
transtition: "flow"
}, 100);
contentItem.screen.showPopup("FullScreenPhoto");
function displayPhoto(element) {
$(element).css({
'min-width': '100%',
'min-height': '100%',
'width': '100%',
'height': '100%',
'display': 'inline'
$(element).find("div.msls-image-border").addClass("responsive");
$(element).find("img").removeProp("style");
$(element).find("img").addClass("responsive");

Hi All,
I have found a solution :-)
myapp.ViewProduct.FullScreenPhoto_postRender = function (element, contentItem) {
// Write code here.
// to fix the popup not screen-centered at the Fist Click when photo is "Fit to Content"
var myimg = $(element).find("img");
$(myimg).one('load', function (e) {
var container = $(element).closest("div.ui-popup-container.ui-popup-active");
// Ref source: css-tricks.com/snippets/jquery/get-an-images-native-width/
// Create new offscreen image to test
var theImage = new Image();
theImage.src = myimg.attr("src");
// Get accurate measurements from that.
var imageWidth = theImage.width;
var imageHeight = theImage.height;
// Ref source: stackoverflow.com/questions/7060422/center-item-on-screen-with-jquery
var obj = $(container);
var obj_width = $(container).outerWidth(true);
var obj_height = $(container).outerHeight(true);
var window_width = window.innerWidth ? window.innerWidth : $(window).width();
var window_height = window.innerHeight ? window.innerHeight : $(window).height();
if ($(window).width() > imageWidth) {
$(container).animate({ left: (window_width - obj_width) / 2, top: (window_height - obj_height) / 2 }, 0);
else {
$(container).animate({ left: 0, top: 0 }, 0); //for very large image
element.title = "Click to close";
$(element).css({
'cursor': 'pointer'
$(element).click(function () {
contentItem.screen.closePopup("FullScreenPhoto"); //click to close
Thanks to ezanker & QuickFix at the link Jquery Mobile Popup not centered on first click (http://stackoverflow.com/questions/21304763/jquery-mobile-popup-not-centered-on-first-click?rq=1) and Center an element on the screen using jQuery (http://www.queness.com/code-snippet/6853/center-an-element-on-the-screen-using-jquery) and CSS-Tricks at http://css-tricks.com/snippets/jquery/get-an-images-native-width/ and at Chris Ingis http://stackoverflow.com/questions/7060422/center-item-on-screen-with-jquery

Similar Messages

  • HT4199 when I set my network airport to lock, it doesn't stay locked and neighboring families networks popup on my screen, and the lock clicks open.  Why doesn't it stay in the locked position?

    when I set my network airport to lock, it doesn't stay locked and neighboring families networks popup on my screen, and the lock clicks open.  Why doesn't it stay in the locked position?  JOHNPEG

    Open the Security pane of System Preferences and set it to require a password to unlock each secure pane. This is designed to stop people using the computer from changing the settings and won't do anything if an issue on the computer itself causes the change.
    (51259)

  • I signed up for sync on one computer and got a pairing code on the second computer but now I can't bring up the pairing screen on the first computer. Why not?

    I set up sync on the first computer, then got a sync code on the second computer. Now I can't bring up the sync screen on the first computer to sync them together.

    Hi shopper104, <br>
    # Click the Home button (or type about:home in the location bar) to bring up the default Firefox home page.
    # At the bottom of the home page, click the Sync link to open the Sync settings window.
    # Then click the Pair a device link and the Firefox Sync Setup window will open.
    # Enter the twelve character code generated on your other device and click Next.
    # When the code is accepted you will see a Device Connected message and your device will immediately begin syncing. Click Finish to close the setup window.
    <br><br>
    More information can be found in these articles:
    * [[Firefox Sync - Take your bookmarks, tabs and personal information with you]]
    * [[How do I set up Firefox Sync?]]
    * [[How do I add a device to Firefox Sync?]]
    Hope that helped you! Please report back.

  • Trackpad of MacBook Pro mid 2009 does not respond to the first click/tap

    Have the following problem and wasn't able to find any sollution here somewhere
    if I click on a link or choose a checkbox or do anything by clicking it does not work with the first click/tap and I have all settings right.
    a PRAM reset had no effect on that problem.
    so I still have to click/tap several times to access a menu, a safari-tab, or anything else…

    thank you.
    still I am not sure if it really solved my problem, but it looks very good.
    was a bit irritated in the beginning, because I got no feadback if I had done the SMC reset right.
    If the problem will be back too soon, I will continue this discussion.
    THX

  • Firefox icon in the Taskbar will not start on the first click, sometimes needing to click 2 or 3 times for it to open (and this is after a fresh reboot with Firefox not running in Task Manager.

    Upon a fresh reboot the Firefox icon in the Taskbar will not work on the first click, sometimes it will not work at all and I need to go to Start-> then click the Firefox icon in the Start menu. Why is it that the icon won't start up on the first click?

    Same issue - however firefox will open but I can not click on only of my tool bar shortcuts - the writing on the google age is greyed out so I can not click on anything. Still no resolution? I have deleted the folders and re-installed - it will open and then locks and it will not work????

  • When initiating an e mail to someone with several addresses used in the past the one I use most often does not come up in the first position.  How can I get these multiple e mails prioritized?

    When initiating an e mail to someone with several addresses used in the past the one I use most often does not come up in the first position.  How can I get these multiple e mails prioritized?

    We are talking about the Mail app, right? In the Mail menubar, click on Window and then Previous Recipients:
    That eliminates the previous recipients. If you are talking about the suggestions because there are 10 people with the name 'Steve' in your Contacts, then I do not know how to eliminate those unless you change the name slightly or wait until you type the last name or some other differentiator.

  • I want to save with alt s in the program Exact Online. This function is not working. this is the first time that i use this program with firefox.

    Question
    I want to save with <nowiki><alt><s></nowiki> in the program Exact Online. This function is not working. this is the first time that i use this program with firefox.
    '''edit''', mod escaped the '''<nowiki><s></nowiki>''' to prevent line through question

    Submitted too soon... To change your accelerator key for accesskeys to Alt alone (or a different combination), you can change a setting using Firefox's about:config preferences page.
    (1) In a new tab, type or paste '''about:config''' in the address bar and press Enter. Click the button promising to be careful.
    (2) In the filter box, type or paste '''ui.k''' and pause while the list is filtered
    (3) Make sure '''ui.key.generalAccessKey''' is set to its default value of -1 (or right-click and choose Reset if it is not).
    (4) Double-click '''ui.key.contentAccess''' to open a dialog box to change the value from its current default (on Windows, 5) to your choice of the following:
    * 2 = '''Ctrl''' (Fx default on Mac thru Fx13)
    * 3 = Ctrl + Shift
    * 4 = '''Alt''' (IE/Chrome/Safari default on Win/Linux)
    * 5 = '''Alt + Shift''' (Fx default on Windows & Linux)
    * 6 = '''Ctrl + Alt''' (Fx default on Mac from Fx14) (Chrome/Safari default on Mac)
    * 7 = Ctrl + Alt + Shift
    This should take effect as soon as you OK the dialog, so you can experiment in a separate tab. Other combinations are available if you want to try them. See http://kb.mozillazine.org/Ui.key.contentAccess (inaccessible at the moment?)

  • Purchased 2 iphone 5's.  Both have cracked the screen in the first week.  Never had this problem with the previous versions iphones being so fragile.

    I purchased 2 iphone 5's.  One for my husband and one for me.  Both have cracked the screen in the first week. I even have a case on mine. Never had this problem with the previous versions iphones being so fragile.  Has anyone else experienced this?

    Tests by some of the web sites and magazines claim that the iPhone 5 is in fact more rugged than previous models. That doesn't obviate the possibility of an assembly defect that would make yours more susceptible to damage, but if you dropped or impacted them and they cracked, then your warranty will not apply and you'll have to pay for replacement, either the AppleCare+ "deductible", if you purchased AppleCare+ with your iPhone, or Apple's normal out-of-warranty replacement charge.
    You can of course make an appointment at an Apple Store, explain the situation, and hope that there's something they can do for you. Don't count on it, though.
    Regards.

  • How do I move an icon from the second page of my home screen to the first page  and vice versa?

    How do I move an icon from the second page of my home screen to the first page and vice versa?

    Hold an icon down until they all wiggle.
    Drag it wherever you want it.

  • Downloads do not appear all (only the first two) in the download statusbar (could be a ff19 or downloadhelper or unmht problem)

    downloads do not appear all (only the first two) in the download statusbar (could be a ff19 or downloadhelper or unmht problem) and none in the download window
    used ff19
    with
    Download Statusbar v0.9.10 by Devon Jensen
    UnMHT v6.2.0 by http://www.unmht.org
    DownloadHelper v4.9.14
    had to revert to ff18.0.2

    Make sure that you do not run Firefox in (permanent) Private Browsing mode.
    *https://support.mozilla.org/kb/Private+Browsing
    *Tools > Options > Privacy: Use custom settings for history
    *Deselect: [ ] "Always use private browsing mode"
    Did you try to disable other extensions?
    *https://support.mozilla.org/kb/Troubleshooting+extensions+and+themes

  • Firefox has gummed up by yahoo mail. 1/2 the time the email doesn't open, it doesn't 'move' on the first click. Anyone else have these problems?

    My yahoo email has many 'delays' when trying to open and I have to hit "retry" and generally that doesn't work either. Since I downloaded the new FFox, it's awful! I'm sorry, but it is. I have these problems on both of my desktop computers.
    Also, when I try to 'move' an email to a yahoo folder, it generally won't move on the first click, but takes 2 or 3 or more to get the email moved. What did you people do?
    Vicki

    IF you have restored your iPhone and still have these problems, you have a defective iPhone and there is nothing anyone here can help you with -- you have to contact Apple for service.

  • I began to purchase songs off iTunes, a prompt message appears whether you want to buy the song after the first click... I ticked the box to say I didn't want this warning again... But now I wish I had that - Anybody know how to get that message back???

    I began to purchase songs off iTunes, a prompt message appears whether you want to buy the song after the first click... I ticked the box to say I didn't want this warning again... But now I wish I had that - Anybody know how to get that warning/prompt message back???

    Sign-in to your iTunes Store account (Store menu > View my account).
    At the bottom of the Account Information page is a Reset box to click to reset all warnings for buying and downloading.  Click the "Done" button when you're finished.

  • Issue in FF v 3.6.10: I have a page which have more than 20 link, clicking on these link opens up a popup using window.showModalDialog, for the first 20 popup opens up without any prob but for the 21st n more click it block the popup and do not open.

    Issue in FF v 3.6.10: I have a web page which have more than 20 link, clicking on each of these link opens up a pop-up using window.showModalDialog, for the first consecutive 20 popup opens up without any prob but for the 21st n more click it block the popup and do not open. This is m problem, the real user on the web page can click on more than 20 link in such a scenario it may create problem, please help

    Your above posted system details show outdated plugin(s) with known security and stability risks.
    *Shockwave Flash 9.0 r999
    Update the [[Managing the Flash plugin|Flash]] plugin to the latest version.
    *http://www.adobe.com/software/flash/about/
    In Firefox 3.6 and later versions you need the Next-Generation Java™ Plug-In present in Java 6 U10 and later (Linux: libnpjp2.so; Windows: npjp2.dll).
    http://java.com/en/download/faq/firefox_newplugin.xml
    See also http://java.sun.com/javase/6/webnotes/install/jre/manual-plugin-install-linux.html

  • h:CommandLink : Action event not called on the first click

    Hi,
    I am facing a problem here.
    I have a JSF page:
    When I first load the page, I have few text boxes and dropdowns. With out doing anything If I click the <h:commandLink I call an action in my pagecode.
    But the problem is on the very first load of the page, without doing anything if I click on the command link action event in my pagecode is not called, but If I click on the link the second timethe pagecode actionevent is called.
    So I think tried submitting the form in the JSF page onclik of the commandlink it works in my Local IBM RAD. But doesnot work in the WebSphere Portal.
    So can you tell me if I can submit the form atleast once when the page loads for the first time
    This is my command link:
    <tr>
    <td colspan="2" align="center">
    <h:commandLink styleClass="commandLink" id="lnkBtnCreateUser" action="#{pc_Createuser.doLnkBtnCreateUserAction}">
    <hx:graphicImageEx styleClass="graphicImageEx" id="imgBtnCreateUser" value="/theme/images/btnCreateUser.gif" style="border:0;cursor:pointer" onclick="return onFormSubmit();"></hx:graphicImageEx>
    </h:commandLink>
    </td>
    </tr>
    function onFormSubmit(){
    //enabling all the disable components
    So can anybody please help me on this. Why exactly the pageCode action event is not called for the very first click ???

    seems that a prependID="false" attribute in the respective form was causing the trouble. At least it's working now that I've deleted it.
    I introduced it, because last time the component ID's messed up the output of the error/success messages ("j_id:xxx isn't that of a usefull information to the enduser).
    Edited by: stger on Apr 9, 2008 5:41 PM

  • Firefox does not load any sites the first time, including Firefox itself, other browsers do.

    In the last few days I have experienced a problem logging on to nearly every site the first time. I get the message that the connection was reset....we have 3 identical computers in our home and I am the only one experiencing this problem. I can immediately try again and log on, but it is annoying to get that message with all sites, including Firefox itself, I have tried to clean out my cache and my cookies, but the problem persists.
    Also, firefox is locking up my computer frequently. As it is as I attempt to send this message. I will copy and past this into another message as soon as I restart my computer.

    Hi cor-el,
    Yes the problem has reappeared, so I tried bypassing the cache for my Windows computer as you suggested: Hold down the Shift key and left-click the Reload button, or "Ctrl + Shift + R" (Windows) I then clicked on my bookmark (http://mdotnetpublic.state.mi.us/drive/ ) and I still see a blank screen and a spinning wheel. This seems to go on indefinitely. But like before I posted the question, when I click the reload button it forces the page to load right away.
    [running Firefox 32]
    I appreciate your quick responses, and look forward to more suggestions. I'll also search the support pages for information about my problem.
    Thank you.
    Mbr9743

Maybe you are looking for