Page not refreshing on Back button |
[eluser]mihaibaboi[/eluser]
Hello. I've got a problem with page refresh when I hit the Back button. So, here's the example. I get a list of items from the database and put a delete button in front of every one. I hit delete, and I'm redirected to the same page, with all the records, except the one I've deleted. That's all fine, but if I hit Back I see the page, including the deleted record (of course, if I hit refresh it's back to normal). I figured the page was cached and I tried to override that, but it did't work. Here's the code, so you can spot any possible mistakes. The Controller: Code: <?php The View: Code: <?php The code isn't the most elegant I've ever written, but it's just a mock-up for proof of concept (this is a problem that was indicated to me by a friend). Also, you will notice that it's using CodeIgniter 2.0. For the record, it does exactly the same on 1.7.2.
[eluser]rossmurphy[/eluser]
Try using base_url() in the link to the delete method instead of simply a relative uri Or use the anchor method from the URL helper.
[eluser]mihaibaboi[/eluser]
It doesn't have anything to do with the URL in the Delete button. The Delete method works just fine. Also, the index() method works fine. My problem is when I hit the back button. I thought that it just sends back to the previous URL (witch is http://localhost/codeigniter/index.php/main). In stead, it goes to that URL, but doesn't reload the controller, so I see the old page. I hope I'm making myself clear. If you need any more details please ask.
[eluser]rossmurphy[/eluser]
Change this: $this->index(); to redirect('main');
[eluser]mihaibaboi[/eluser]
[quote author="rossmurphy" date="1291814542"]Change this: $this->index(); to redirect('main');[/quote] Hey, this actually works. Don't know why yet. I'll have to go look at the docs. Thanks.
[eluser]pickupman[/eluser]
That's because $this->index() just runs a function/method that happens to be another url and returns the html. Essentially using this syntax you could load every single method in a controller from one method, and have one crazy looking output. Using redirect() creates a 301 redirect which makes the browser go to a new url, and load the new page. |
Welcome Guest, Not a member yet? Register Sign In |