Welcome Guest, Not a member yet? Register   Sign In
templates and javascript
#3

[eluser]gullah[/eluser]
EDIT: The code tags seem to remove the script links but they are in there, probably where it says [removed]

This is the template library I'm using.
Code:
class Template {
        function load($template = '', $view = '' , $vars = array(), $return = FALSE)
        {
                $this->CI =& get_instance();
                $vars['template_contents'] = $view;
                if ($template == "mainTemplate")
                        return $this->loadMainTemplate($view, $vars, $return);
                else
                        return $this->CI->load->view($template, $vars, $return);
        }


        function loadMainTemplate($view, $vars = array(), $return = FALSE)
        {
                if( ! isset($vars['head_title']))
                        $vars['head_title'] = "Default Title";

                return $this->CI->load->view("mainTemplate", $vars, $return);
        }
}

This is my main template file without extra junk
if I take this js file out I get the following error
Quote:jQuery is not defined
flash.js()()flash.js (line 1)
[Break on this error] jQuery.noConflict();

which is in the flash.js file

Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
   "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

&lt;html &gt;
    &lt;head&gt;
        &lt;meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /&gt;
        &lt;title&gt;&lt;?=$title?&gt;&lt;/title&gt;
        &lt;?=link_tag('style/reset.css')?&gt;
        &lt;?=link_tag('style/style.css')?&gt;
        
        &lt;link href="&lt;?=base_url().$this-&gt;config->item('FAL_assets_front').'/'.$this->config->item('FAL_css');?&gt;/fal_style.css" rel="stylesheet" type="text/css" />
        [removed][removed]
        [removed]config->item('FAL_assets_shared').'/'.$this->config->item('FAL_js');?&gt;/flash.js" type="text/javascript">[removed]

    &lt;/head&gt;


    &lt;body&gt;
                      

                        &lt;!--STAR FLASH MESSAGE--&gt;
                        &lt;?php
                        $flash=$this->db_session->flashdata('flashMessage');
                    
                        if (isset($flash) AND $flash!='')
                        {?&gt;
                            
                            <div id="flashMessage" style="display:none;">
                                
                                &lt;?=$flash?&gt;
                            </div>
                        &lt;?php }?&gt;
                        &lt;!--END FLASH--&gt;

This is my view without the junk
if I take this one out I get this error
Quote:jQuery is not defined
[Break on this error] jQuery.noConflict();
flash.js (line 1)
jQuery is not defined
[Break on this error] })(jQuery);
jquery.form.js (line 601)
$ is not defined
[Break on this error] $(document).ready(function(){
(line 103)
Code:
[removed][removed]
[removed][removed]

[removed]

    $(document).ready(function(){

    &lt;?php foreach(array_unique($javascript) as $id) : ?&gt;
        $('#show_&lt;?=$id?&gt;').click(function() {
            if($('#show_&lt;?=$id?&gt;').attr('value')=="Show all comments for this meaning") {
                $('#show_&lt;?=$id?&gt;').attr('value', 'Hide Replies');
            } else {
                $('#show_&lt;?=$id?&gt;').attr('value', 'Show all comments for this meaning');
            }
            $('.&lt;?=$id?&gt;_replies').toggle('slideDown');
        });
    &lt;?php endforeach; ?&gt;
    &lt;?php foreach(array_unique($meaningsIds) as $meaningId) : ?&gt;
        $('.meaning_&lt;?=$meaningId?&gt;').click(function() {
            $('.meaning&lt;?=$meaningId?&gt;').fadeOut('slow', function(){
                $('.meaningEdit_&lt;?=$meaningId?&gt;').fadeIn('slow');
            });

            
        });
        $('.form_&lt;?=$meaningId?&gt;').ajaxForm(function(data) {
          if(data==0) {
              $('.meaningEdit_&lt;?=$meaningId?&gt;').fadeOut('slow', function(){
                  $('.meaning&lt;?=$meaningId?&gt;').fadeIn('slow', function() {
                      $('.meaning_content_body_&lt;?=$meaningId?&gt;').append('<b>Success! You must refresh the page for the changes to take effect</b>');
                  });
              });
          } else if(data==1) {
                $('.meaningEdit_&lt;?=$meaningId?&gt;').fadeOut('slow', function(){
                    $('.meaning&lt;?=$meaningId?&gt;').fadeIn('slow', function() {
                        $('.meaning_content_body_&lt;?=$meaningId?&gt;').append('<b>The edit failed please try again.</b>');
                    });        
              });
            }
          });
    &lt;?php endforeach; ?&gt;    

    
    
    });  

[removed]

It seems that they both need their respective jquery load or they aren't given access to jquery at all.


Messages In This Thread
templates and javascript - by El Forum - 12-14-2008, 12:17 PM
templates and javascript - by El Forum - 12-14-2008, 06:01 PM
templates and javascript - by El Forum - 12-15-2008, 09:57 AM
templates and javascript - by El Forum - 12-15-2008, 10:24 AM
templates and javascript - by El Forum - 12-15-2008, 10:55 AM
templates and javascript - by El Forum - 12-15-2008, 12:22 PM
templates and javascript - by El Forum - 12-15-2008, 12:24 PM
templates and javascript - by El Forum - 12-15-2008, 12:41 PM
templates and javascript - by El Forum - 01-15-2009, 05:00 PM



Theme © iAndrew 2016 - Forum software by © MyBB