Wrong controls initialed on page refresh - orbeon

https://gist.github.com/773373
Non relevant fields are initialized on page refresh.
Steps to reproduce
Access the page. Notice the two alerts. "init - uncheck" and "enabled - uncheck".
Select the check box. Check control is initialized. Two alerts again. This control was not relevant previously.
Refresh the page (I am using firefox). Notice the non-relevant control is initialized but the relevant control is not. You can tell from the alerts.
Interestingly the right component is shown but xforms-enabled is called on the wrong component.

Getting those 2 alerts for the non-relevant control on page refresh is normal. However, after those, you should also get alerts for the newly relevant control. I created a bug for this, and will update this response when the issue is fixed.
When you do a reload (ctrl-r) on Firefox, the HTML is in its initial state, as it was the first time the page was loaded. However, since Firefox resets the form fields to their value before the reload, we can detect with JavaScript that a reload happened, and the browser can ask the server "please tell me everything I need to do on the initial HTML to put it back to state X". The server resends all the events it sent when you clicked on the checkbox, except the <xxf:script>, which is responsible for your script running, hence the behavior you observe.
We did some brainstorming on this issue, and described a solution, which at this point still need to implement.

Related

surveymonkey popup not showing

I setup a wordpress blog and wanted to add a popup from surveymonkey. To simply test if it gets loaded I added the script within the footer.php before the closing body tag. Then I reloaded the page but the popup didn't appear, I tried the same with an empty html page where it did work.
Then I compared the developer console and it seems that not everything gets loaded. For some reason after the object has been loaded nothing else gets loaded. I even tried to add the script to another project (not wordpress) but it doesn't work either.
I also tried to setup a new collector and added the script tag again to my project. The popup has been loaded, but after I reloaded the page the same happens as before. It does work though when I use an embedded survey, instead of a popup survey.
Here are my results on firefox:
Any page
Empty page
What am I doing wrong here?
Wanted to add in the edit This is the correct answer but also I wanted to give context to why the default nature SurveyMonkey creates here is not good. If the end user activates the survey a single time the fact that it would not open again makes no sense and is a poor user experience.
The user would never know, if they closed the survey prematurely, that there was no reason that the activation of the survey could not be completed again.
SurveyMonkey allows for the survey to be taken again until it is completed and then the survey would explain to the user they have already completed the survey. This is a good user experience and sufficient.
***End edit
Just chiming in here, despite this being an old question. The previous answer is absolutely correct as the Survey Monkey popup will only display once and there's nothing you can do via the Survey Monkey interface to get it to show multiple times in a single browser session.
However, you can resolve this issue by adding the following JS above your Survey Monkey JS code:
<script>document.cookie = 'smcx_0_last_shown_at=;expires=Thu, 01 Jan 1970 00:00:01 GMT;';</script>
This code clears a cookie created by the Survey Monkey pop up that keeps track of when it was last displayed, so it'll display every time the page is refreshed without the need to end the current browser session.
I know this is an old question, but I am posting a reply in case it helps someone else. It appears that Survey monkey limits the number of time the pop up shows to once per browser session.
I have tested in Chrome, Firefox & Edge and I was able to reproduce this behavior very consistently.
If either the embed or the pop has shown up once, the pop up will not show up a second time until you either close and re open the entire browser, or load the page in incognito/private browsing mode. But you will still need to close and re open the private/incognito browser window/tab each time you reload the page containing the pop up.
As of yet, I have not found an option within the Survey Monkey interface to disable this behavior for the pop up survey. Note that the embed survey does not suffer from this.

PhoneGap transaction not triggering its first parameter after changing jQuery Mobile page and getting back

On a jQuery Mobile page, I call the PhoneGap Storage function like this:
window.database.transaction(performQuery, error);
And it works. I can use it several times, and it always works.
Then, I use jQuery.mobile.changePage() to change to a different page, then call history.back() from that second page, and back to the original page performQuery() does not get called anymore.
I placed alert() functions both before and after the call to transaction(), and placed one at the beginning of the definition for performQuery(), but the third alert() is never reached after getting back from the second page.
This also occurs with a transaction I put on the second page. It works the first time the second page opens, but it doesn't when I get back to the former page and then back to the second page again.
Also to be noted this question might have the same answer as this other question, although I cannot be sure.
It turns out the culprit is the OS. According to a workmate, Android Honeycomb gives trouble in this regard, something to do with the page change.
Anyway, things work as expected on a different Android device.

Alternative way of Page.IsPostBack

I am into iPhone, Android and Blackberry web programming. I am struck into an issue in which i either need to stop refresh of page (which according to blogs is not possible) or i need to just refresh the page rather than submitting.
I have used basic HTML controls not ASP.Net server controls, so Page.IsPostBack cannot be used to differentiate between page refresh and a postback.
Alternatives that i have tried:
The root of the issue is that : Having used Request.Form Collection which are read only and are only updated on a postback. So, on a page refresh the Request.Form collection is having previous values and thus submits according to previous request.
I have tried using cookies as found in this link: http://hi.baidu.com/cxyking/blog/item/508872346135283c5ab5f53c.html
It is able to detect a page refresh only after it has already loaded. While my requirement is that i need to detect page refresh before the original page has been unloaded.
I tried to use OnBeforeUnload to display some warning message. But, this only works in desktop browsers and iOS does not seem to do anything on this event.
Is there any idea on how i can do any one of following:
Completely stop page refresh.
Display warning message to user for not leaving the page (OnBeforeUnload not working on iOS)
Somehow, update Request.Form Collection (Note that it has a Set but it is readonly, so it doesnt work)

How can I make something similar to that cool bar on the top of stackoverflow that pops up when you get a new badge?

When you get a new badge on stackoverflow.com, a bar appears at the top of the screen informing you of your achievement. It sticks around until the user closes it.
I rather like that system of informing the user about new news related to the site or their account. It's fairly unintrusive, but still clearly communicates the information. Even if all users receive a notification this way, it sticks around for each user until they have acknowledged seeing it.
I'm running a system using Ruby on Rails on a PostGres database. What's the best way to implement a similar system on my setup?
Edit: Just to clarify, I'm interested both in the server side and client side of the setup.
The effect can be accomplished with jQuery and the slideDown method (http://api.jquery.com/slideDown/). Set an onClick event to make the element slideUp, hide, or hit an AJAX call to let you know that the user got the message and dismissed it.
You could set the contents of the element (I'd go with a div) via an AJAX call, or you could simply populate the div with the appropriate message when generating your page, start the div off as hidden, and then kick off the slideDown method when the page load is complete via a $(document).ready definition (http://think2loud.com/jquery-document-ready-howto/).
You could use something like the jquery popup bubble extension: http://www.farmcode.org/post/2009/04/06/jQuery-popup-bubble-extension.aspx

IE6's back button and repost

My website is an asp.net-mvc(beta1) website, fully validates and works in all browsers (except obviously in IE6 for this matter).
I can reproduce the error by doing the following:
Make a POST request with some parameters
From the results click one of the generated GET links
Pressing the "BACK" button from the resulted page.
Sometimes the back button does nothing (last request's page keeps on screen, status says "Done")
Sometimes a completely empty page is shown with the correct URL and the "Done" status
Sometimes the res://ieframe.dll/repost.htm page is shown with "Cannot find server" title.
I have yet to find the triggering factor..
I'm guessing IE is not caching anything there so it will re-post the url. Nothing seems to be hitting my controller though.
What is happening? How can I start to debug this or even better: fix this?
Implement POST+REDIRECT+GET?
IE won't re-post without prompting the user. If IE isn't caching the results page (check what cache headers you are sending it), you should get the repost prompt. I don't know why you'd get 'Server not found' instead - sounds like a confused IE installation. (Is it a multiple-IE setup?)
As cletus mentioned, post-redirect-get is generally desirable for successful post forms.
To analyze the traffic between browser and server you should put Fiddler in bewteen.
This way you'll find out if IE6 sends any request at all back to the server upon hitting the back button.

Resources