Skip to:
Content

BuddyPress.org

Opened 12 years ago

Closed 7 years ago

Last modified 7 years ago

#4500 closed enhancement (wontfix)

Ajax loading doesn't refresh JS onload

Reported by: sgr33n's profile sgr33n Owned by:
Milestone: Priority: normal
Severity: normal Version:
Component: Templates Keywords:
Cc:

Description

Hi,

It's a bit difficoult to explain this without an example.
So... when BP loads activity streams, do some initialization operations, such hide long lists of activity comments, only show the latest five root comments... maybe the theme coder want to add other stuff... anyway... when you do things like ajax loading of more elements (at the bottom of the page) or change tab (favorites i.e.) the initialization doesn't happen, so you will see in example all comments of an event (maybe also 1000 or more) and things like that. This maybe happen also if the coder would add other jquery stuff like tipsy or scrollpane, autoresize etc. etc.

Maybe would be useful to add a function bp_reinit() where you can put all that functions you need to launch at startup.

In my case i found 2 events where to add it:

after:

		/* Update the feed link */
		if ( null != response.feed_url )
			jq('.directory #subnav li.feed a, .home-page #subnav li.feed a').attr('href', response.feed_url);

		jq('.item-list-tabs li.selected').removeClass('loading');
		'''sgrbp_reinit(500);'''

after:

				jq("#content li.load-more").removeClass('loading');
				jq.cookie( 'bp-activity-oldestpage', oldest_page, {
					path: '/'
				} );
				jq("#content ul.activity-list").append(response.contents);

				target.parent().hide();
				'''sgrbp_reinit();'''

And this is the function:

function sgrbp_init() {
	bp_dtheme_hide_comments()
}
function sgrbp_reinit(timeout) {
	setTimeout(function(){sgrbp_init()},timeout);
}

Bye :)

Change History (5)

#1 @DJPaul
11 years ago

  • Milestone changed from Awaiting Review to Future Release
  • Type changed from defect (bug) to enhancement

It sounds like you want the idea of WordPress do_action hooks in our default javascript.

It's unlikely we'll do any serious plumbing to BP-Default's javascript, and some theme compatibility changes that we're building into 1.7 and 1.8 will probably end up with all-new javascript (thus removing the problem). We'll be sure to keep in mind to consider custom jQuery events or other techniques to provide this sort of thing going forwards.

#2 @vhauri
10 years ago

Unless BP turns off the fact that ajax in jQuery is global, you can actually accomplish this hook without code modifications. If you hook your method to the jQuery.ajaxComplete() function, you'll get access to the url as a property of the third function param. This means you can check each completed ajax request on the page, test the URL for a match, and if it matches, run your ajax knowing that new content, etc. was just loaded via ajax. You also get the XMLHttpRequest object as the second param, so you can confirm success, etc. before firing your custom actions.

Check out more info here: http://api.jquery.com/ajaxComplete/#ajaxComplete-handlerevent--XMLHttpRequest--ajaxOptions

That being said, what I just suggested above is all kinds of a hack, and it would be awesome to replace that with published events.

#3 @DJPaul
8 years ago

  • Component changed from Appearance - Template Parts to Templates

#4 @DJPaul
7 years ago

  • Milestone Future Release deleted
  • Resolution set to wontfix
  • Status changed from new to closed

Closing most tickets related to BP-Default and BP-Legacy, since the upcoming BP-Nouveau template pack (planned for 3.0) will make these redundant.

#5 @DJPaul
7 years ago

Closing most tickets related to BP-Default and BP-Legacy, since the upcoming BP-Nouveau template pack (planned for 3.0) will make these redundant.

Note: See TracTickets for help on using tickets.