web-tiki web-tiki - 6 months ago 47
Javascript Question

Joomla Ajax loading for contact form component

I am trying to implement ajax loading for the joomla 3.2.1 default contact form component.

I set a menu link to the contact form in the backend.

This is the HTML output :

<nav id="menu2">
<div class="moduletable">
<ul class="nav menu">
<li class="item-138"><a href="/contact">Contact</a>
</li>
</ul>
</div>
</nav>


and I have this div at the bottom of the page :

<section id="contact_form">
</section>


I implemented this Jquery code :

$('.item-138 a').click(function () {
$('#contact_form').load("index.php?option=com_contact&view=contact&id=1&tmpl=component")
return false;
});


The contact form loads well and my template override works. but how can I prevent loading the
<head>
content that comes with it?


The
<title>
tag, default scripts (mootools jquery...) and default css (
/templates/system/css/general.css
,
/templates/system/css/template.css
)

Can I do that with a template override? Is it even possibler?

Answer

Well there is this value that you attach to the get request.

&format=raw

so your request looks like

index.php?option=com_contact&view=contact&id=1&tmpl=component&format=raw

also you may want to make a copy of your view.html.php and rename it view.raw.php