• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Jquery, Tabs, CI Forms, and page refreshs....

Ok, I've been poking around for the last two days on the CI and Jquery sites looking for a solution.

I'm using Jquery Tabs with my CI app. I'm using the "hijack links" functionality inside of the tabs, so that clicked links will load inside the tabs properly. So far so good.

When clicking around the app, normal links work fine. As soon as I click a link that has a form in it, there's a full page refresh to the form view.

I'm not quite sure where the error is: jquery with the link hijacking, or CI with refreshing the page.

Here's the jquery Tabs code...
    $(function() {
        load: function(event,ui) {
        $('a',ui.panel).click(function() {
        return false;

...and here's the tab generation.

<div id="tabs">
        <li><a href="#Home">Home</a></li>
        <li><a href="/index.php/members/blah"><span>blah</span></a></li>
        <li><a href="/index.php/members/blah2" title="blah2"><span>blah2</span></a></li>
        <li><a href="/index.php/members/blah3"><span>blah3</span></a></li>
        <li><a href="/index.php/members/blah4"><span>blah4</span></a></li>
        <li><a href="/index.php/members/blah5"><span>blah5</span></a></li>
    <div id="Home">
Home Div


You can see where I've been screwing around with the code.

Here's the edit link that page refreshes; this is the whole View file.

<div id="blah2">
&lt;?php echo validation_errors(); ?&gt;

&lt;?php echo form_open('members/editblah/' . $this->uri->segment(3)); ?&gt;

*snip*...lots of &lt;input type&gt; here...*snip*

&lt;input type='submit' value='Submit'&gt;


And now finally the controller function...

function editblah()
            $this->form_validation->set_rules('frmfriendlyname', 'Friendly Name', 'trim|required');

        if ($this->form_validation->run() == FALSE)
                    $this->load->view('/members/editblah', $data);


Is there a smack-my-forehead reason why it does a page refresh, as opposed to loading into the <div>? All the other pages load into the divs/tabs fine; only the form page fails.

Any help appreciated!


It's most likely the jquery plugin IMHO. BUT...you could use firebug to determine whether CI returns a 301/302 redirect to confirm.

EDIT: actually, a redirect would reset your page. Definitely NOT CI.

EDIT AGAIN: Sorry, I guess it wouldn't since the whole transaction is handled by ajax, but you should still be able to tell from my first suggestion. Big Grin

Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  

  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2021 MyBB Group.