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()

How would you load it from a module?
$Core.loadStaticFile(getParam('sJsStatic') + 'jscript/colorpicker/js/colorpicker.js');
hello raymond, following my code is not working, i tried, can u check if i am doing anythng wrong
<script type="text/javascript" >
$Behavior.onClickEvents = function()
{
$(".delete").click(function(){
var element = $(this);
var I = element.attr("id");
$('li#list'+I).fadeOut('slow', function() {$(this).remove();});
return false;
});
});
</script>
There is a small syntax error in the sample code provided:
$Behavior.onClickEvents = function(){
$('a').click(function(){
alert('clicked!');
return false;
});
});
It should look like this:
$Behavior.onClickEvents = function(){
$('a').click(function(){
alert('clicked!');
return false;
});
};
There is an extra close parenthesis ")" (without quotes) at the end of the script (after the last literal tag, before the last semicolon). You have this in your code as well. Since the Behavior method doesn't require the function to be placed inside of parentheses, the extra closing parenthesis is not needed. Removing it might fix the issue.
Either that, or you can try adding an open parenthesis to the beginning of the first function after the equal sign "=" on the first line of code.



