Welcome Guest, Not a member yet? Register   Sign In
Maintaning Jquery Tab State After loading view
#1

[eluser]RaGe10940[/eluser]
Hi,

Me again, and yes its about my emailing subject Tongue

I am using Jquery Tabs for different views on my email page... best way for me to ask this question is show a video of the problem :

so low and behold :
http://www.youtube.com/watch?v=F4elvhznE8E


This is my code :



Code:
if (!$this->email->send()) {
      $data['error'] = '<p class="error">Email Could Not Be Sent. Please Try Again</p>';
      $this->load->view('emailsystem/emails_view', $data);
  } else {
      $this->session->set_flashdata('emailview', 'Email Sent To ' . $email . '');
      redirect('email_controller/emailview', 'location');
  }
     } else {
  $data['error'] = $this->upload->display_errors('<p class="error">', '</p>');
  $this->load->view('emailsystem/emails_view', $data);
     }

Do I have to specifically tell the view which tab to go to?

HTML (for the most part) :

Code:
[removed]
     $(function() {
  $("#tabs").tabs();
     });
[removed]
&lt;style type="text/css"&gt;
     @import "&lt;?php echo base_url(); ?&gt;javascript/themes/smoothness/jquery-ui-1.8.4.custom.css";
&lt;/style&gt;
    &lt;/head&gt;
    &lt;body&gt;
<div id="wrapper">
     <div id="header"><img src="&lt;?php echo base_url(); ?&gt;images/masterheader.jpg"></div>
      <div id="tabs">

  <ul>
      <li><a href="#student">Find Student</a></li>
      <li><a href="#onlyemail">Send Email</a></li>
      <li><a href="#massemail">Mass Email</a></li>
  </ul>
  <div id="student">
      &lt;?php
      $anum = 'placeholder="A Number" autocomplete="off"';
      $first = 'placeholder="First Name" autocomplete="off"';
      $last = 'placeholder="Last Name" autocomplete="off"';
      $email = 'placeholder="Email" autocomplete="off"';
      $subject = 'placeholder="Email Subject" autocomplete="off"';
      ?&gt;
      <br>
      <div id="emails">
   <div id = "emailinfo">
       &lt;?php
       echo form_open_multipart('email_controller/sendemail');
       echo form_input('anum', set_value('anum'), $anum);
       echo form_input('fname', set_value('fname'), $first);
       echo form_input('lname', set_value('lname'), $last);
       ?&gt;

   </div>
   <div id="subject">
       &lt;?php
       echo form_input('subject', set_value('subject'), $subject);
       ?&gt;
   </div>
   <div id="message">
       &lt;textarea name="message" rows="3" cols="60" placeholder="Email Message (Optional)"&gt;&lt;?php echo set_value('message') ?&gt;&lt;/textarea&gt;
   </div>
   <div id="attachment">
       &lt;input type="file" name="files[]" multiple /&gt;
   </div>
      </div>
      <div id="sendemail">
   &lt;?php
   echo form_submit('submit', 'Send Email');
   echo anchor('staff_controller/index', 'Return');
   echo form_close();
   ?&gt;
      </div>
  </div>
  <div id="onlyemail">
      <div id="emails">
   &lt;?php echo form_open_multipart('email_controller/outside_email'); ?&gt;
   <div id="out_email">
       &lt;?php echo form_input('out_email', set_value('out_email'), $email); ?&gt;
   </div>
   <div id="subject">
       &lt;?php
       echo form_input('out_subject', set_value('out_subject'), $subject);
       ?&gt;
   </div>
   <div id="message">
       &lt;textarea name="out_message" rows="3" cols="60" placeholder="Email Message (Optional)"&gt;&lt;?php echo set_value('out_message') ?&gt;&lt;/textarea&gt;
   </div>
   <div id="attachment">
       &lt;input type="file" name="files[]" multiple /&gt;
   </div>
      </div>
      <div id="sendemail">
   &lt;?php
   echo form_submit('submit', 'Send Email');
   echo anchor('staff_controller/index', 'Return');
   echo form_close();
   ?&gt;
      </div>
  </div>
  <div id="massemail">
      <p>mass email</p>
  </div>
     </div>
#2

[eluser]TheFuzzy0ne[/eluser]
When you submit the form, you should submit it with the URL hash. I couldn't see from the video whether or not it's automatically updated in your address bar when you click on a new tab. If it is (which is a good idea, because people can then bookmark your tabs), then just leave the action attribute empty. If it doesn't, then you need to use Javascript to modify the URL each time a tab is selected, or use redirect() to redirect to the correct URL (complete with URL hash), once the email has been submitted. Redirecting is a good idea, because it prevents forms from being resubmitted when users click the back button.

You may also need to add some Javascript that automatically displays the right tab when the page loads, using the URL hash as a reference.

Hope that makes sense.
#3

[eluser]RaGe10940[/eluser]
Yes I understand where your coming. and no there is no url hash... this seems like its going to be a pain in the butt. How do I add a hash the CI url?
#4

[eluser]TheFuzzy0ne[/eluser]
You won't need to if you set it using Javascript. See http://stackoverflow.com/questions/19390...-in-jquery.

From your view, when you open your form, just do this:
Code:
echo form_open_multipart();

Your form should now submit to whatever's in the address bar, and will include the URL hash when the page reloads, so you can display the correct tab again, (which is also outlined in the stackoverflow page I just linked to).
#5

[eluser]RaGe10940[/eluser]
Mkay...

I'm getting the hash now in my URL...

https://www.finaidtest.com/index.php/ema...ew#student

and I also removed all of the

echo form_open_multipart(............);

leaving me with : echo form_open_multipart();

now I get nothing being send to the controller...

This is my jquery :
Code:
[removed]
     $(function() {
  $("#tabs").tabs();
  $('#tabs ul a').click(function(event) {
      event.preventDefault();
      $('#tab').hide();
      [removed].hash = this.hash;
      $($(this).attr('href')).fadeIn('slow');
  });
     });
[removed]
#6

[eluser]TheFuzzy0ne[/eluser]
Please could you post your entire view, (with the Javascript inline), on http://pastebin.com?

I'll be able to set this up and test it on my server.
#7

[eluser]RaGe10940[/eluser]
Actually Fuzzy, I abandoned that idea. When it comes down to it, my boss doesn't even know what Jquery UI is or even Jquery for that matter..

I just used links for different pages.

as always thanks -> your like my guiding angel Tongue
#8

[eluser]TheFuzzy0ne[/eluser]
[quote author="RaGe10940" date="1364659819"]Actually Fuzzy, I abandoned that idea. When it comes down to it, my boss doesn't even know what Jquery UI is or even Jquery for that matter..

I just used links for different pages. [/quote]

The simplest solutions are usually the best, and they require less maintenance. I'm sure you could always look into it in the future some time if you ever let your curiosity get the better of you. Smile

I suspect the way you had it originally, wasn't degradable, either -- which is something that could potentially cause headaches for, and angry clients/bosses.

[quote author="RaGe10940" date="1364659819"]as always thanks -> your like my guiding angel Tongue[/quote]

More like a mis-guided missile... PoW!
#9

[eluser]RaGe10940[/eluser]
Of course. There is no difference in the tab vs. The links just as fast imho and I can customize the links allot easier. Less headaches all around<3




Theme © iAndrew 2016 - Forum software by © MyBB