I have been racking my brain over this. I thought this module supported ajax loading of NEW items beyond those (say 9 that were selected to display in the view), but then I realized that the carousel is just cycling through those 9 items I specified for the view over and over again (appearing as though it was loading NEW items beyond the 9 specified via ajax).

Maybe I misunderstood the ajax functionality to mean ONLY that it keeps (say 4 items) in view and calls the 9 total items via ajax when I select next. If you wouldn't mind correcting my confusion, I would appreciate it, as I'm starting to think that this is not really the solution I was looking for. I was imagining that loading would occur more like "Infinite scroll."

This, of course, would be an extremely useful feature.

CommentFileSizeAuthor
#5 jcarousel_views3.patch2.25 KBquicksketch

Comments

Equinger’s picture

Title: Is this module supposed to support Ajax in Views 3? » Is this module supposed to support ajax loading of new content (beyond the number specified) in Views 3?
Equinger’s picture

For example, if your view was of NID's, and you chose to display "all items" in the Views menu, then the view DOES originally have to load ALL of the items, no?

Equinger’s picture

Thoughts? Thanks.

quicksketch’s picture

Yes, jCarousel should support AJAX in the way you describe. If you show 3 items at a time, but have 9 items loaded by default (using the number of items option in Views), then the first 3 pages are pre-loaded and further pages are loaded by AJAX.

However, jCarousel doesn't work with Views 3 properly until you apply this patch: #996416: Does not use views query substitutions.

quicksketch’s picture

Title: Is this module supposed to support ajax loading of new content (beyond the number specified) in Views 3? » AJAX support does not work in Views 3
Category: support » bug
StatusFileSize
new2.25 KB

Okay, I found that even after committing #996416: Does not use views query substitutions, jCarousel still doesn't work right in Views 3. I've found this work-around which fixes the problem, but I'm going to check into it further before committing.

Equinger’s picture

Really appreciate your attention to this! I'm excited for this to work. Will keep following up.

quicksketch’s picture

Status: Active » Fixed

Sorry all my patches have gotten a little mixed up with each other as I was trying to merge them together. The above patch contains a lot of unnecessary code from other issues, but it also fixes the problem while not breaking Views 2 (still doesn't fix D7 Views 3 though :P).

I've committed this change and I'll get out a 2.2 version shortly.

Status: Fixed » Closed (fixed)

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

Equinger’s picture

Category: bug » feature

I think everything is working properly. Is there any way to specify how many items an ajax load will display. It seems to do 3 at a time by default.

Equinger’s picture

Category: feature » bug
Status: Closed (fixed) » Active

Please excuse me if there have been further updates here that I am unaware of, but I noticed a new problem. When the Views JCarousel using ajax is on the page w/ other views using ajax, Views Jcarousel ajax updating is broken after the View using an ajax filter is used.

The reason for this is that the Drupal.settings.views.viewsAjax object is updated improperly. The properties held by the carousel are overwritten by another object.

I have a hackish solution. Basically, I clone the Drupal.settings.views.viewsAjax object in the following way when Drupal.behaviors.jcarousel in the jcarousel.js is run for the first time:

if(typeof Drupal.settings.jcarousel.ajaxViews==="undefined") {
			Drupal.settings.jcarousel.ajaxViews = $.extend(true, {}, Drupal.settings.views.ajaxViews);
		}

I then utilize the Drupal.settings.jcarousel.ajaxViews object that is unaffected by my other views to keep things running smoothly. Obviously, there is a deeper problem w/ the interaction between the Views, but this is the solution quality I can achieve w/ the time I have.

Equinger’s picture

OK, I still think there is work to do to make this compatible with Views 3. It seems to me that caching will require for this View to be pluggable. Currently the module works through changing the offset of the view, which means that the same set of results get returned over and over again. I think something like the following would need to be implemented instead (using Views Infinite Scroll as a reference which does function with caching):

class views_plugin_pager_infinite_scroll extends views_plugin_pager_full {
function query() {
    parent::query();

    $next_page = TRUE;
    if (!empty($this->options['total_pages'])) {
      if (($this->current_page + 1) >= $this->options['total_pages']) {
        $next_page = FALSE;
      }
    }
    if ($next_page) {;
      $limit = $this->options['items_per_page'];
      $this->view->query->set_limit($limit + 1);
    }
  }
}

It seems that setting a new "limit" triggers a new query to run. Changing the offset does not seem to run a new query.

Equinger’s picture

Quick update. Tried to add: $view->set_current_page(($last)/($last-$first)), since it appears that this is a factor in caching (see cache_set in views_plugin_cache), but it is not helping.

murz’s picture

Title: AJAX support does not work in Views 3 » jCarousel: AJAX support does not work in Views 3

Subscribe

quicksketch’s picture

Status: Active » Closed (fixed)

When the Views JCarousel using ajax is on the page w/ other views using ajax, Views Jcarousel ajax updating is broken after the View using an ajax filter is used.

See #1006830: jCarousel does not work with Exposed Filters or Sorts.

JCarousel works equally well with Views 2 or Views 3, this problem affects both versions. Let's keep this issue closed, as there's nothing wrong with the normal AJAX ability in Views 3.