Store
Community Documentation

v3 Knowledgebase

Working with jQuery and phpFox v3

With phpFox v3 we introduced a new feature where your users can browse your community using a method we are calling AJAX browsing. In order for jQuery events to continue working you will need to wrap it in our $Behavior namespace.

Here is an example of our old method for v2
$(function(){
	$('a').click(function(){
		alert('clicked!');
		return false;
	});
});


Our new method would be
$Behavior.onClickEvents = function(){
	$('a').click(function(){
		alert('clicked!');
		return false;
	});
});

Notice where we have onClickEvents. This is the only part you will have to change. This must be a unique name and is always good to use your products name to create your own namespace.

Within this behavior there are no special rules and you can access all of jQuery without any extra code. Additionally you can place behaviors anywhere in the script and we will pick it up and execute it once the document is ready.

To sum it up the $Behavior namespace is like jQuery's ready() function.

If you are going to implement a JQuery Plugin the file that you need to write is similar to the file /static/jscript/colorpicker.js
You can see how this file loads other static files by means of:
$Core.loadStaticFile(getParam('sJsStatic') + 'jscript/colorpicker/css/colorpicker.css');
$Core.loadStaticFile(getParam('sJsStatic') + 'jscript/colorpicker/js/colorpicker.js');

And implements the routine in the $Behavior namespace:
$Behavior.designProfilePage = function()