Forums

ChronoForm Displays but it doesn't

tlegens 13 Sep, 2012
Ok, I have a really weird situation. I have a top level menu category list layout. On my contact category, I have a form on the contact page for a general contact. The client wanted the same form on another page in the same category. so I created another page in the category and placed the same form in the article. so, different pages, same category, same form.

If you navigate to the sub page the form displays and has no issues. However, if you go to the main category page, the form doesn't show and I also noticed other items like my search box text and menu active states were missing. So I went into the console and found a javascript error...


TypeError: $("chronoform_lshform") is null
http://mcgwebsites.com/web/lsh/contact-us.html
Line 36


So, that got me looking for conflicts. first of all, I am loading jquery above the loading of my joomla head and also loading and external file with jquery.noconflict. I've tried switching that to a local script block but no changes occurred. I have also disabled everything I have that ran jquery and still notice the error and no form. Seems strange the the code would work fine on the sub page but not the main category page even with all my jquery items. I have placed the head code area for the website below. Any suggestions are welcome.

Affected pages:
http://mcgwebsites.com/web/lsh/contact-us.html (category main level)
http://mcgwebsites.com/web/lsh/contact-us/leave-a-comment.html (category sub page)


/* The following line loads the MooTools JavaScript Library */
JHTML::_('behavior.framework', false);

/* The following line gets the application object for things like displaying the site name */
$app = JFactory::getApplication();

/* The following line loads the Joomla Document and then use variables to load different template items */
$doc = JFactory::getDocument();
$doc->setGenerator('Medical Consulting Group');
$params = &$app->getParams();
$pageclass = $params->get('pageclass_sfx');
$syspath = $this->baseurl.'/templates/system/';
$path = $this->baseurl.'/templates/'.$this->template;
?>
<?php echo '<?'; ?>xml version="1.0" encoding="<?php echo $this->_charset ?>"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="<?php echo $this->language; ?>" lang="<?php echo $this->language; ?>" dir="<?php echo $this->direction; ?>" >
<head>
<!-- Include JQuery -->
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script>
<!-- Include JQuery noconflict -->
<script type="text/javascript" src="<?php echo $this->baseurl ?>/templates/<?php echo $this->template ?>/js/jquery.noconflict.js"></script>
<jdoc:include type="head" />
<link href='http://fonts.googleapis.com/css?family=Lato:400,700,900' rel='stylesheet' type='text/css'>
<link rel="stylesheet" href="<?php echo $this->baseurl ?>/templates/<?php echo $this->template ?>/css/reset.css" type="text/css" />
<link rel="stylesheet" href="<?php echo $this->baseurl ?>/templates/<?php echo $this->template ?>/css/menu.css" type="text/css" />
<link rel="stylesheet" href="<?php echo $this->baseurl ?>/templates/<?php echo $this->template ?>/css/template.css" type="text/css" />
<link rel="shortcut icon" href="favicon.ico" type="image/x-icon" />

tlegens 13 Sep, 2012
Ok, so I changed that menu structure for that part to be just an article. Amazingly, the form works on both pages. it is still however interfering with my pages. I still show the undefined error and it's wrecking havoc on my home page.
GreyHead 14 Sep, 2012
Hi tlegens,

Both forms look OK (using FireFox), I have no idea why the ChronoForms files are showing on the Home page though. They should only be loaded if there is a form on the page.

Bob
tlegens 14 Sep, 2012
Yeah, I can't figure out why it's displaying there either. I also can't figure out why the no conflict is not working. It's clearly defined right after jQuery at the top of the page.

Wow, the strangest thing. I just noticed that the contact us page was set to the same category as the home page article was set to. I set it to the category of contact (like it should have been) and the behavior goes away. Is this a bug? Why would an article that is not even being displayed add a script for that article component to a page? Very strange.
tlegens 14 Sep, 2012
Bob, when I put the article back into the category of contact and then made the menu a category list again, I was back to the form not showing for the category but did show for the sub article. What I ended up doing was stripping out the chronoform plugin from the article, creating a chronoform module for the form, then using loadposition for each article. It works great now.

So to recap for those following on, I needed to use the same form for two different pages in the same category, one instance of the form was loaded into the category description using the chronoform plugin while another instance was created doing the same thing but in an article. This caused a conflict and did not display the form for the first instance as well as stopped other scripts on the page. Replacing the category list with just an article layout worked but did not meet my needs. Consequently, accidentally placing that article within the same category as my home page, stopped all the scripts on the home page even though the article was not included on the page.

Solved by creating a module and using loadposition for each article/category I needed to have the form display. I hope this makes sense and helps someone that may run across this at some point.


Tom
This topic is locked and no more replies can be posted.