Welcome Guest, Not a member yet? Register   Sign In
Jumping to an Anchor Point on load->view?
#1

[eluser]Vik[/eluser]
I've got some help buttons on my pages. When the user clicks a help button, a help box appears next to the button. It seems like the right way to do this may be to have the page reload, revealing the help text next to the button, and have an anchor point so that when the page reloads it goes straight to the anchor point for that help text.

Later on I'll add Javascript to reveal the help text, but first I'm doing a version of the site that works even if people don't have Javascript installed.

Is there a way to load a view and jump to an anchor point within that view? (Or an alternate/better way of handling this?)
#2

[eluser]obiron2[/eluser]
why not use <A HREF = "//path/to/help/html" target="_new"> click this link</A>

This will open the help file in a new window.
#3

[eluser]Alex007[/eluser]
In the view, make your anchor like this:
[code]
<a name="help_goes_here">
[code]

And when you reload your page, add #help_goes_here at the end.
[code]
http://www.yourdomain.com/controller/fun..._goes_here
[code]
#4

[eluser]Vik[/eluser]
[quote author="Alex007" date="1193684028"]In the view, make your anchor like this:
Code:
<a name="help_goes_here">

That works in plain html, but it doesn't appear to currently work with the CI load function. If I try:

Code:
$this->load->view('your_plan_views/new_plan_view#TestAnchor', $data);

I get an error message:

Quote:An Error Was Encountered

Unable to load the requested file: your_plan_views/new_plan_view#TestAnchor.php
#5

[eluser]Vik[/eluser]
[quote author="obiron2" date="1193675956"]why not use <A HREF = "//path/to/help/html" target="_new"> click this link</A>

This will open the help file in a new window.[/quote]

Popup windows and things that simulate them seem to be frowned upon. Here's an example of a discussion on this subject.
#6

[eluser]xwero[/eluser]
A hack that requires javascript (jquery) could be
Code:
//controller
function page()
{
$data['goto'] = '<span id="goto">help_goes_here</span>';
$this->load->view('view',$data);
}
// javascript
$(function(){
  if($('#goto').length == 1)
  {
    var id = $('#goto').text();
    $('#goto').remove();
    $("html,body").animate({ scrollTop: $("#"+id).offset().top });
  }
});
// view
&lt;?php echo $goto; ?&gt;
...
<div id="help_goes_here">help to the rescue</div>




Theme © iAndrew 2016 - Forum software by © MyBB