I'm trying to create a link on my page that goes to a page with the right id. The page where the link is is at: http://localhost:3000/quotes/9942/marketingScheduleShell. Once the link is clicked the page should redirect to http://localhost:3000/quotes/9942/.
Something along these lines is how I want this to work but when I try the code below it just takes me to the /quotes/ page.
<a href='http://localhost:3000/quotes/' + #quote.id>Show</a>
How can I use the id of the quote object I click on to go to the correct page for that object?
The only think you need is a link_to method
link_to('Show', quote_path(#quote))
Also reading some guides would save you a lot of time: http://guides.rubyonrails.org/
Related
I have an issue in MVC to go with anchor from one view to a section in another view without the hash in the URL to be displayed. I am navigating in my Controler's views like normal /news or /test, but I want to go to a section of the Index view and I am doing it with /#contact. I have tried to javascript it and remove it from the visual URL with the following solution:
window.location.href.substr(0, window.location.href.indexOf('#'))
and this:
history.pushState(obj, title, url);
But this is not helping, because the URL is not updating at the time of the first click. I tried to delay the event with some ms, but it is not pro at all... Can you give me some advices or hints to remove #contact from the URL and still be on the section "contact" of the View.
I am at a bit of loss of knowledge and honestly don't know what to search for. What I need to be able to do is determine what content to show on a webpage that way when I refresh it will not reset everything. For example, if someone clicks on the messages tab I want the browser to know when it refreshes, that is the tab to stay on. I believe this is done through url encoding but I am not sure. Any help would be AWESOME! Thanks fellow coders.
MORE INFO: I have 2 buttons on a page. One is named "home" and when I click it I want the content of the home page to appear in a box named "info-main". I am doing this with ajax requests. When I click on "edit profile", I want the content in div id "info-main" to be replaced with the edit profile information that is retrieved via ajax as well. I need to figure out how if someone refreshes the page... I want it to stay showing the edit profile information rather then going back to the default of "home" content.
MORE INFO(AGAIN)
I just had a great idea. When the page refreshes, I want it to load specific ajax code based on what the url encode is.
For example.... if the url is:
http://www.exampleurl.com/index.php?info=status-load
I want the browser to execute the ajax I have for retrieving status's.
OR
If the url is:
http://www.exampleurl.com/index.php?info=edit-prof
I want it to load the ajax code I have for retrieving profile edit info.
I really hope this helps. :/
The way I do it is I place a # before the link i.e. href="#messages"
Then I link a .js with this code.
$(function () {
var hash = location.hash
, hashPieces = hash.split('?')
, activeTab = $('[href=' + hashPieces[0] + ']');
activeTab && activeTab.tab('show');
});
I hope this helps
For referring an element on your page, you use a link with a hashtag.
For example, if you have a layout like this:
<div class="top-nav">
Home
Edit Profile
</div>
And you have a password edit form on your editProfile page, you can like to it like this:
Edit Profile
if you have a <form id="passwordChange"> on your editProfile.
Read more: http://css-tricks.com/hash-tag-links-padding/
This is a webpage with a number of "subpages" embedded in ajax for all the user reviews.
http://www.goodreads.com/book/show/13636400-the-bone-season#
I am trying to get the specific URL for particular pages (say ?page=4), so I can point people to particular reviews directly instead of going to the page and clicking on page4. below is a snippet from the source code for that page:
<a href="#" onclick="new Ajax.Request('/book/reviews/13636400-the-bone-season?page=4', {asynchronous:true, evalScripts:true, method:'get', parameters:'authenticity_token=' + encodeURIComponent('XsOgyhAC4p0tAm8wGIqTQGY+PxGpDieI45AYry0NlE4=')}); return false;">
when i type http://www.goodreads.com/book/reviews/13636400-the-bone-season?page=4, i get a blank page.
What do I need to do get the page to show? Thank you!
You can get the url for the specific reviews, but I was unable to find anyway to do so for the "page". If you want to direct someone to a specific review, then you can get that url from the "see review" link or the date link on that particular review.
New answer: you need to submit a GET request (using cURL for example) with the parameter mentioned ('authenticity_token=' + encodeURIComponent('XsOgyhAC4p0tAm8wGIqTQGY+PxGpDieI45AYry0NlE4='), and parse what is sent back. Then you'll get your review. Linking to it is not possible unless you find a URL where your review is always displayed.
This is my web structure. In which all link contents are opened in iFrame when link is clicked.
Say I have clicked on 1st link (not Home page) , it gets open in iFrame,contents are displayed properly,all ok. But as I press refresh button expected is shlould load same page whose link I have clicked,but instead of that it loads Home page.
How should I be on same page after refresh also?
I'm using php for server side scripting. Thanks!
Edit:
I tried to store visited page name in session variable and then while loading Home page I check like
$_Session['visited']='/pages/neworder.html';
if(isset($_Session['visited']))
{
echo "<script>window.location.href=</script>".$_Session['visited'];
}
But didnt work!
I think the simplest way is with Jquery. If you make your website use anchors, for example
http://yoursite.com/#page-example
example
When you refresh the page, you will still be accessing this anchor. With jquery you can get this value and do some stuff based on that. So!
var hash = $(this).attr('href').split('#')[1];
This will get that # value, you can compare that in javascript then, or use a switch to determine what to do or simulate the page change.
Server side: Link sends GET request to the page and the src of the iFrame is set by the server.
-OR-
Client side: Add onclick function on the links which changes the src atribute for example with the following code:
document.getElementById('Iframe').src="new link";
-OR-
<iframe src="startin_link" name="iframe_a"></iframe>
<p>link</p>
Pure html.
EDIT: If you want to stay in the page... I suggest you use the first option. Example:
<a href='?page=1'>Some link</a>
then on server side:
if(!is_null($_GET['page'])){
$iframeLink=arrayOfLinks[$_GET['page']];
}else{
$iframeLink="Starting Link";
}
and the iFrame should look like this:
<iframe src='<?php echo $iframeLink; ?>'></iframe>
Is it possible to use FB share plugin without APP ID?
If I use HTML5 code then the console logs an error FB.getLoginStatus() called before calling FB.init().
To use HTML 5 FB like is it necessary to have an APP ID?
Thank you
Here i am sharing what i did to share post on fb wall, In this way you do not need to use appId. Just put this code in your HTML page where you want link to share...
<a name="fb_share" type="button" href="http://www.facebook.com/sharer.php?u={$url}&media={$imgPath}&description={$desc}" class="joinFB">Share Your Advertise</a>
URL parameters are as explained below,
u : url or link you want to user to go when he clicks on your wall post,
media : full image path,make sure that image is available on given path,it will accept one image only
description : a short description that you want to show on wall
It will also ask you to write some data which will be displayed above your post. Description passed in url will be displayed in right side of your image.
Please note that i had passed $url,$desc,$imgPath variables as per my need. The above code is in smarty-php, so change it as per your requirement.
Hope this becomes helpful to you.
Yes you need an app id. You can try to inject your own code into the DOM of the user when using facebook and call functions in their javascript... But I doubt many users will actiually use an "app" that works this way.