Annulé

JQuery/PhpFox: Last 10% of an ADGallery integration

I have integrated AdGallery ([url removed, login to view]) into Phpfox for the user profile photos section. I added some extra code to use the phpFoX AJAX functionality to get comments and photo details for each photo when clicked.

The problem is that with each AJAX call done through phpfox a javascript function called loadInit() is run which does the following:

$('*').unbind();

$.each($Behavior, function()

{

this(this);

});

This removes all the event triggers from the gallery and so it no longer works after the first AJAX call. If I create a new function loadInit2 and change it to this:

$.each($Behavior, function()

{

this(this);

});

And then force phpfox to use that function during AJAX instead, then everything in the gallery still works as the events are still binded, however it has 2 drawbacks; firstly it requires editing core phpfox files rather than being a plugin, and secondly it causes quirky behavior with comments, such as each additional comment without a page reload will add 2 duplicate comments, then 3, then 4 etc. And I really want to get this working without ugly hacks.

So onto the problem. You can set '$Behaviors' in phpfox javascript files which will be binded after each run of the loadInit function by phpfox. So it should be easy to rebind everything. However, the gallery was not designed to be instantiated twice (obviously) so if I do the following

$Behaviors addGallery = {

var galleries = $('.ad-gallery').adGallery();

}

It works fine the first time the page loads, but after an ajax call (when it runs this behavior again after unbinding and rebinding all the $Behaviors) it gets totally confused trying to start from scratch when a gallery is already there and I get very odd behavior such as image thumbnails sliding all over the place, images overlapping, next/prev buttons not working correctly etc.

Sadly JQuery is my weakest skill and the gallery code is beyond me. What I need doing is the creation of two functions, or the splitting of the single adgallery function. I need the gallery to be initialized on page load as it is now, then I need a new function (or part of the original) which can be run with each AJAX call which will rebind all the necessary Jquery events for the gallery without causing any abnormal behavior, ensuring all buttons (e.g next/prev image) and thumbnail navigation work correctly.

Compétences : AJAX, jQuery / Prototype, PHP

Voir plus : jquery rebinding, phpfox jquery, jquery adgallery, function working phpfox, photo editing profile, phpfox function call, gallery jquery phpfox, behavior phpfox, reload page jquery, jquery reload page, quirky, prev, plugin jquery, jquery image, change functionality, change skill, jquery easy, jquery instead, without page reload, jquery easy php, jquery behavior, jquery image add, jquery force, php ajax thumbnail, comment section ajax

Concernant l'employeur :
( 0 commentaires ) Peterborough, United Kingdom

N° du projet : #2351796