I'm having an issue with the search and reference functionality.

When I open a search and reference modal frame window I'm able to select a node to reference without problems. If I open the search and reference window and perform any paging or filtering I can no longer select any nodes to reference.

This happens with both the grid and table view.

Has anyone else had this issue?

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

MarcElbichon’s picture

I have the same problem. I've corrected it by replacing line

 Drupal.attachBehaviors($view.parent());

by

 Drupal.attachBehaviors($view.parent().context);

in views\js\ajax_view.js

R.J. Steinert’s picture

I'm debugging this problem right now in 6.x-1.6-dev. @MarcElbichon I'm not sure we're experiencing the same bug.

After poking around for a bit I noticed that $('td.views-field-noderelationships-nid', table).each(... was coming up null after updating the view (with search, pager, etc.) and not iterating over the rows in the table. Looking at the markup, after updating the view (using pager, searching, etc.) I noticed that the classes on the tags of the tables have change. For example, when you first load the view in the modal each

that contains the nid has class=views-field-noderelationships-nid (which matches the jquery selector, this is good) but when you update the View that same comes back with class=nid (which does not match the jquery selector, this is bad).

So the question is, why does the markup for the view come out differently after being updated?

R.J. Steinert’s picture

Version: 6.x-1.6 » 6.x-1.x-dev
Status: Active » Needs review
FileSize
1.19 KB

Spelunking noderelationships.inc I don't see any difference in the resulting variables during run time when the view is loaded normally vs when the view is loaded with ajax. Perhaps the root of this problem is an assumption about Views output that is no longer true, but someone who is more familiar with this code could probably tell.

So, given that we can't assume that views will add the classes the rest the noderelationships javascript expects, here's a patch that adds those expected classes using javascript in case they don't exist so we get the desired behavior after an ajax load of the view.

MarcElbichon’s picture

Patch has no effect for my problem.
My problem is following :

I've a view with exposed filter. When I open search popup, row selection works
When I change expose filter and clik on apply, row selection doesn't work.
With Firebug, i see context var contains another context var.
With hack #1, context var contains only document var
Rather than hacking views javascript, this code do the trick

Drupal.behaviors.nodeRelationshipsReferenceDialog = function(context) {
  var self = Drupal.nodeRelationshipsReferenceDialog;
  if (context.context) {
      context = context.context;
  }
 ...
R.J. Steinert’s picture

I'm seeing an undefined context variable is passed into Drupal.behaviors.nodeRelationshipsReferenceDialog after updating filters or the pager. So, setting context = context.context doesn't help because context.context is also undefined. It seems really strange that context would be undefined... Maybe Modal is screwing up Drupal.behaviors?

@MarcElbichon I'm using 6.x-1.x-dev. Which version are you using? Also, are you using jquery_update module? Views version and Modal version may be a factor as well..

MarcElbichon’s picture

Jquery-update 2.0 alpha1
Views 2.x-dev
Modal frame api 6.x-1.7
Node relationships 6.x-1.6

kongoji’s picture

I managed to make it work for me trimming the nid and title in noderef_dialog.js

Zatox’s picture

I used patch #3 for a table style with the same issues. It did work but since I use "title" and "nid" views fields to build some other tds, the classes were added to those to: so I had my extra columns hidden. I modified the code added by the patch to this:

  // When the view is loaded using ajax it doesn't come back with the proper classes, add them.
  sanityCheck = $('td.views-field-noderelationships-nid', table);
  if (sanityCheck[0] == null) {
    $('tr').each(function() {
       var tr = $(this);
       var td = tr.children();
       td.eq(0).addClass('views-field-noderelationships-nid');
       td.eq(1).addClass('views-field-noderelationships-title');
    });
    $('th.nid:eq(0)').addClass('views-field-noderelationships-nid');
    $('th.title:eq(0)').addClass('views-field-noderelationships-title');
  };

This way tds are not targeted by their class who are the same but by their position (first and second). I'm assuming the two columns always appear in first so this should work for any custom view. (it works on my custom view). Pretty much the same logic for the headers.

I have another issue but I'm posting it here because i think it is related, at least, to #5:
I'm using rjstatic's oa_noderelationships (1.1) module to solve theming problems. Paging and filtering cause the pager to, somehow, go through the template.php of my OA theme (wich is based on Gingko) and not Garland as it should. I guess it is related to the undefined context variable rjstatic was talking about in #5
So it seems the ajax goes through views normal ajax system without it being processed by noderelationships.

Zatox’s picture