I need to navigate to a new page, then call a specific function in that page.
In other words, open a page when a certain box is collasped/hidden etc.
Should I pass parameter from page1 to page 2 ? how ?
Can I call a function from page1 to page2 then navigate (using wix.location ) ?
So you can use wix-location to pass a queryParam to the page you're going to and then just run a code in the other page that reads from the URL.
Wix-location API
Hope this helps..
Related
How to remember the currently opened page in the pagination of the membersloop in Buddypress, so when visiting a profile and coming back to the membersloop, it gets opened on that page?
I saw that in buddypress-nouveau.min.js?ver=1.7.8:formatted the ajax call is done via the JS function objectRequest() but it gets called with the "page: 1" parameter as a fixed value.
Is there a way to override this?
I have Custom Visual force page MyPage1 and on click of a button , I am calling /Apex/MyPage2 and also I am passing some input parameters as part of '/apex/MyPage2?accname={!Account.Name}&accid={!Account.Id}';
I am performing some activity in MyPAge2
and at the end, I want to returb back FinalVariable back to MyPage1
how I can pass back the response to calling VF page (MyPage1)?
please help
Communication between pages can be achieved using Javascript :
Listener() function in parent page.
Postmessage() function in chile page
how open url with click on one div in Watin automation
i am going to url by this code
browser.GoTo(address);
browser.WaitForComplete();
and click on a div like this
var main_tab1 = browser.Div(Find.ByText("main_tab"));
main_tab1.click();
i want when browser going to url the div be cliked
and no need to click ... and the automation will be faster
I am not sure if I have understood your question right. You are asking whether you need to navigate to page on click on Div using browser.Goto(address)? If so, try to navigate directly to the address. Capture the URL when u click on the div and send it to GOTO method.
i click on a button
var repbtn = browser.Button(Find.ById("btnReply"));
repbtn.Click();
and goto a page after click on btnReply
and in this page i have 4 tabs that i must click on one of theme
in this page i capture url with this code
string rep_url=browser.Url;
browser.Goto(rep_url);
and when i click on one of 4 tabs the url not changed that i captured its url
var main_tab = browser3.Div(Find.ByText("main"));
main_tab.Click();
the main_tab Div have onclick method , do i run this method even url loading .
From my view I am sending via $.ajax a JSON object to my controller to save it in the database.
If all succeeded i want to redirect to another action which will show a diferent view.
If i use this code:
return RedirectToAction("CreatePage", "Survey", new {id = question.PageId});
The execution goes to the Survey controller which returns a view but it is not shown.
I have read some post which said that it is not posible to redirect via ajax.
The solution I use so far is to redirect via javascript like this:
success: function (ret) {
window.location.href = "/Survey/CreatePage/" + $("#PageId").val();
}
Although this always works, sometimes i need to refresh the CreatePage view to show the last changes made.
Any idea of how to solve this problem better?
Thanks in advance
As mccow002 suggested, I wasn't really needing to make the call via AJAX for that part. After studying the solutions suggested, i realized that i could simple submit it in a form. My confusion came because I have a save and continue editing and a save. For the save and continue I use the AJAX call, but for the save option with the form being submitted is ok.
Thanks very much for your help.
Instead of redirecting to a new page, you can send a rendered html from .net code back to client and load that html in page, like this $("#main").load(renderedHtml).
But for refreshing the page you can write a simple script that run at specified intervals and refresh the page contens.
You could use [OutputCache] on the CreatePage action so that it doesn't cache the page or only caches for so long.
output caching
This is probably going to get a resounding no, but I am wondering if it possible to have the URl change dynamically with using hashing, and without invoking a http request from the browser?
My client is keen on using AJAX for main navigation. This is fine, when the end user goes to the front page first, but when they want to use the deep linking, despite it working, it forces an extra load time as the page loads the front page, then invokes the AJAX from the hash.
UPDATE: Could it be possible, given that what I want to avoid is the page reload (the reason is that it looks bad) to stem the reload by catching the hash with PHP before the headers are sent, and redirecting before the page load. This way only one page loads, and the redirect is all but invisible to the user. Not sure how to do this, but seems like it is possible?
Yes, this is possible. I often do this to store state in the hash part of the URL. The result is that the page doesn't reload, but if the user does reload, they're taken to the right page.
Using this method, the URL will look like: "/index#page=home" or "/index#page=about"
You'll need to write a JavaScript function that handles navigation, and you'll need a containing div that gets rewritten with the contents fetched from AJAX.
Home
About
Questions
<div id="content"></div>
<script type="text/javascript">
function link(page) {
location.hash = "page="+page;
loadPage(page);
}
// NOTE: This is using MooTools. Use the AJAX method in whatever
// JavaScript framework you're using.
function loadPage(page) {
new Request.HTML({
url: "/ajax/"+page+".html",
onSuccess: function(tree, elements, html) {
document.id('content').setProperty('html', html);
}
}).get();
}
</script>
Now, you'll also need to have something that checks the hash on page load to load the right content initially. Again, this is using MooTools, but use whatever onLoad method your JavaScript framework provides.
<script type="text/javascript">
document.addEvent('domready', function() {
parts = location.hash.split('=');
loadPage(parts[1]);
}
</script>
Ok, the problem is that opening an AJAX link of the form http://example.com/#xyz results in a full page being downloaded to the browser, and then the AJAX-altered content is changed once the page has loaded and checked the hash part of its URL. The user has a diconcerting experience.
You can hugely improve this by making a page that just contains the static elements - menus, etc. - and a loading GIF in the content area. This page checks its URL upon loading and dynamically fetches the content specified by the hash part. The page can have any URL you want; we'll use http://example.com/a. Links to this page (http://example.com/a#xyz) now provide a good user experience for users with scripting enabled.
However, new users won't come to the site by fetching http://example.com/a; they'll fetch http://example.com. This is fine - serve the full page, including the home page content and links that don't require scripting to work (e.g., http://example.com/xyz). A script run on loading this page should alter the href of AJAXable links to their AJAX form (http://example.com/a#xyz); thus the first link a user clicks on will result in a full page load but subsequent ones won't.
The only remaining problem is is a no-script user gets sent an AJAX link. You can add a noscript block to the AJAX page that contains a message explaining the problem and provides a link back to the homepage; you could include instructions on how to enable scripting or even how to modify the link by removing a# and pressing enter.
It's not a great answer, but you can offer a different link in the page itself; e.g., if the address bar shows /#xyz you include a link to /xyz somewhere in the page. You could also add a link or button that uses script to bookmark the page, which would again use the non-AJAX form of the link.