Hey all!

Didn't test this without the views calendar ajax pager, and i guess that's okay, but With the ajax pager, this leads to the back to top button being rendered multiple times when you use the calendar pager.

( my js isnt that good, but it's a new page load, so maybe a check should be done to confirm a 'real' page load or a views (or other) pager loading something. )

Comments

Rob C’s picture

Scroll to top has a similar issue at > http://drupal.org/node/1556608 with a patch. Maybe Back to top can use the same fix?

acke’s picture

Assigned: Unassigned » acke
Status: Active » Needs review

Thanks for the report and the pointer the the patch. I used to same solution and pushed it to HEAD. Plz try if it works for you.

Rob C’s picture

Status: Needs review » Reviewed & tested by the community

Welcome!^^

And yes, this indeed seems to fix it. Will test some more later on, but it's fixed for the calendar and other pages with same odd behaviour. RTBC!
(Also did a test with all css stripped, and hard-coded the div in a block, just to see if it would work, and that also works.)

acke’s picture

Status: Reviewed & tested by the community » Fixed

Great! Now in the 1.3 release, http://drupal.org/node/1694072.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

Aurochs’s picture

Thanks but unfortunately it did not fix my issue with views page loader module.
Actually all events in .js should be done only ONCE. And i couldnt catch how its achieved and was diging around to learn to fix also my custom .js code not working due to that. As i learned it is done by assigning a class to the items as already processed via ajax in Drupal 6.
In Drupal 7 its done via " .once " function which is now supported by D7. (Function ".one" is no good, it makes diffr approach.)

So here is how i changed the backtotop .js code and it worked for me:

(function ($) {
	Drupal.behaviors.backtotop = {
		attach: function(context) {
			var exist= jQuery('#backtotop').length;
      if(exist == 0) {
			$("body", context).once(function () {
				$(this).append("<div id='backtotop'>"+Drupal.t("Back to Top")+"</div>");
			});
		}
			$(window).scroll(function() {
				if($(this).scrollTop() > Drupal.settings.back_to_top.back_to_top_button_trigger) {
					$('#backtotop').fadeIn();	
				} else {
					$('#backtotop').fadeOut();
				}
			});

			$('#backtotop', context).once(function () {
				$(this).click(function() {
					$('body,html').animate({scrollTop:0},1200,'easeOutQuart');
				});	
			});
		}
	};
})(jQuery);


Here is my working example: http://gamepart.ru/news

x1d’s picture

Thank you Aurochs this fixed my issue with the "Views Infinite Scroll" module

Rob C’s picture

Status: Closed (fixed) » Needs review

Re-opening the issue so the maintainer might notice it again. (and provide patches, they speed up everything :) )

acke’s picture

Version: 7.x-1.2 » 7.x-1.3
Status: Needs review » Needs work

Thanks... I check the code and commit to dev / 1.4 if I seems to work.

acke’s picture

Issue summary: View changes
Status: Needs work » Fixed

Committed and pushed to HEAD/7.x-dev and going into the 1.4 release.

Thanks for the code!

maximpodorov’s picture

Excuse me, but why is once() needed? I think using context from behavior arguments is enough.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.