Hyperlink without full page refresh

Fred04

Member
Hello,

I created a joomla article with hyerlinks to multiple Fabrik lists. The links work ok but each time it refreshes the FULL page. I only would like to refresh the part of the screen where I have my article and replace it with a Fabrik list.

is it possible? It may be more a Joomla question than a Fabrik one but maybe someone already faced the issue.
 
Sounds like what you need is the J! content plugin for Fabrik, which renders your lists / forms / visualizations in place in the content.

-- hugh
 
I understand the 'content' plug-in and what I can do with it but what I'm looking for is a little bit different.

when I click on a link in an article I want to load the new article (the fabrik's one) in the same article window without reloading the whole page.

should I put some ajax code somewhere?
 
I've no idea if something like that exists in the Joomlaverse, but you could write a content plugin to observe all your links, intercept the click events, run an ajax request to get the fabrik list (based on the link's href property) and then replace the link with the returned result.

heres a rough untested stab at the js you might need to use:

http://jsfiddle.net/5Hq4z/2/

note it wont work in js fiddle but the code should give you some idea of what is required.
 
You could try it old-style. I?ve been using a variation of this ?show/hide? javascript function for years.

Put this function in a *.js file that is being read by your template (Joomla or Fabrik)...

function showfabrik(show_id,hide_id_list){
var hides = hide_id_list.split(",");
for (var i = 0, item; item = hides; i++) {
var varid = document.getElementById('list' + item );
varid.style.display = "none";
}
var show_div = document.getElementById(show_id);
show_div.style.display = "";
}

THAT'S IT.

The 2 parameters passed to the function are "show_id" (the div id of the Fabrik list/form to show) -and- "hide_id_list" (a comma delimited list of the div id?s to hide).

Set up your article so that a content plugin placeholder for each of the Fabrik forms/lists you want to show are enclosed in a div. Assign a unique ID to each div and set the display style to ?none? for all of them. The div containing the Fabrik content you want to show should be passed as the ?show_id? (1st argument) in the javascipt onclick of the URL - and the list/form ids of the others passed as comma delimited list for the 2nd argument to the function (?hide_id_list?).

You can have as many Fabrik content plugin placeholders as you want in the DIVs (probably only limited by memory) ? but you have to pass all the div ids (except the one you want to show) in the ?hide_id_list?.

An example of an article I wrote using this solution is below (better to explain by example)?.

<p>Opening article text blah, blah, blah - Or see lists...</p>
<ul>
<li><a href="#" onclick="showfabrik('list3','61,49');">Job Groups</a></li>
<li><a href="#" onclick="showfabrik('list61','3,49');">Your Profile</a></li>
<li><a href="#" onclick="showfabrik('list49','3,61');">Your Surveys</a></li>
</ul>
<div>
<div id="list3" style="display:none;">{fabrik view=list id=3}</div>
<div id="list61" style="display:none;">{fabrik view=form id=61}</div>
<div id="list49" style="display:none;">{fabrik view=list id=49}</div>
</div>

I should explain - you can use lists or forms of course but the javascript relies on the div ids to have names beginning with "list" (even if the Fabrik content plugin will be displaying a form)

I've used variants of this show/hide function often in Joomla articles. The thing to be careful about is when displaying articles in a blog layout or even 2 "lead" articles on a page. If both articles have the same div ids, the javascript will trigger hide/show in both articles.

A good trick to get around that is to use the php microtime function to initialize a variable that will produce a unique id for each div and use that in both the div id and parameter in the onclick call to the function.
 
I understand the 'content' plug-in and what I can do with it but what I'm looking for is a little bit different.

when I click on a link in an article I want to load the new article (the fabrik's one) in the same article window without reloading the whole page.

should I put some ajax code somewhere?


Not sure if you resolved this one, found this thread whilst looking for something else.

I found this the other day, I haven't tried it out yet though and I have no idea if it will do what you need...... but who knows

http://extensions.joomla.org/extensions/core-enhancements/performance/scripts/13293
 
Actually I looked at it as well but have not tested it. I keep you posted when I will have some free time.
 
We are in need of some funding.
More details.

Thank you.

Members online

No members online now.
Back
Top