page_render problems

edited December 2012 in News & Announcements
Hello,

I am trying to change a site I have developed with codeigniter to fuel cms.

I have a problem with tank_auth.

The live site:
http://www.highlandcoffeeroastery.co.za/auth/userprofile

If I click on the 'send confirmation email' button without filling up the fields, it gives me errors which is correct.

In fuel cms I have a problem, the page is open in a new page to show the errors.

You can see the example here:
http://highlandcoffeeroastery.co.za/new/auth/userProfile

In my auth controller I have a function called change_email.

In there I am rendering a view auth/change_email_form:
$page_init = array('location' => 'auth/change_email_form'); $this->load->module_library(FUEL_FOLDER, 'fuel_page', $page_init); $this->fuel_page->render();

In my change_email_form view I have this jquery:
$('#changeEmail').click(function() { var password = $('#password').val(); var email = $('#email').val(); $.ajax({ type: "POST", url: "<?php echo base_url(); ?>auth/change_email", data: {password: password, email: email}, success: function(data){ $('#emailResult').html(data); } }); return false; });

Although I am rendering the page, I don't get the html declarations so I get the error:
ReferenceError: $ is not defined
so the page opens in a new page and not in the tab.

Can someone please help?

Comments

  • edited 8:17AM
    HTML declerations - are you meaning you're not getting a layout with HTML header/footer?

    What's in auth/change_email_form.php?
  • edited 8:17AM
    Hi Lance,

    Yes I mean HTML header/footer.

    The change_email_form code:
    <div id="emailResult"> <?php $password = array( 'name' => 'password', 'id' => 'password', 'size' => 30, ); $email = array( 'name' => 'email', 'id' => 'email', 'value' => set_value('email'), 'maxlength' => 80, 'size' => 30, ); $attr = array('class'=>'form'); echo form_open($this->uri->uri_string(), $attr); ?> <div class="field"> <?php echo form_label('Password', $password['id']); echo form_password($password); echo '<div class="error">'; echo form_error($password['name']); echo isset($errors[$password['name']])?$errors[$password['name']]:''; echo '</div>'; ?> </div> <div class="field"> <?php echo form_label('New email address', $email['id']); echo form_input($email); echo '<div class="error">'; echo form_error($email['name']); echo isset($errors[$email['name']])?$errors[$email['name']]:''; echo '</div>'; ?> </div> <?php echo form_submit(array('name'=>'changeEmail', 'class'=>'submit', 'id'=>'changeEmail'), 'Send confirmation email'); echo form_close(); ?> </div> <script type="text/javascript"> $('#changeEmail').click(function() { var password = $('#password').val(); var email = $('#email').val(); $.ajax({ type: "POST", url: "<?php echo base_url(); ?>auth/change_email", data: {password: password, email: email}, success: function(data){ $('#emailResult').html(data); } }); return false; }); </script>
  • edited 8:17AM
    Sorry, it has this line at the top as well:
    <?php fuel_set_var('layout', ''); ?>

    But if I removed this line, I get the whole background image in the view, and nothing else. No form.
  • edited 8:17AM
    Ok, it looks like I solved my problem.

    I added this to my change_email_form view:
    <?php fuel_set_var('layout', ''); ?> <!DOCTYPE html> <html lang="en-US"> <head> <title><?php echo fuel_var('page_title', '')?></title> <meta charset="UTF-8" /> <meta name="ROBOTS" content="ALL" /> <meta name="MSSmartTagsPreventParsing" content="true" /> <meta name="keywords" content="<?php echo fuel_var('meta_keywords')?>" /> <meta name="description" content="<?php echo fuel_var('meta_description')?>" /> <?php echo css('main'); ?> <?php echo css($css); ?> <?php echo js('jquery, main'); ?> <?php echo js($js); ?> <script src="http://s7.addthis.com/js/300/addthis_widget.js#pubid=ra-509de4bb2b73c140"></script> <base href="<?php echo site_url()?>" /> <link rel="shortcut icon" type="image/x-icon" href="<?php echo site_url(); ?>favicon.ico" /> </head> <body> ....my form </body> </html>
Sign In or Register to comment.