# HG changeset patch # User Franck Deroche # Date 1232733465 -3600 # Node ID 25a0c2fcbcfbadae3268f6533848788deaafd7c3 # Parent 71a07534c366b908e8bc9d4a2100802ed20e09b2 Don't wrap the field in a div, it may cause problems. Instead, we just go back in the DOM 'till we find the div holding the real data. It's not really all that good, but, it seems to do the job. diff -r 71a07534c366 -r 25a0c2fcbcfb noderef_view.js --- a/noderef_view.js Fri Jan 23 17:03:10 2009 +0100 +++ b/noderef_view.js Fri Jan 23 18:57:45 2009 +0100 @@ -6,8 +6,10 @@ $('.noderef_view_link', context).each(function(i, obj) { $(obj).addClass('noderef_view_link_processed').click(function() { // Get the wrapper - var id = $(this).attr('rel'); - var wrapper = $('#' + id); + var wrapper = $(this).prev(); + while (!wrapper.is('div')) { + wrapper = wrapper.prev(); + } // Suppress behavior if it was previsously attached $(document).unbind('popups_form_success.noderef_view'); diff -r 71a07534c366 -r 25a0c2fcbcfb noderef_view.module --- a/noderef_view.module Fri Jan 23 17:03:10 2009 +0100 +++ b/noderef_view.module Fri Jan 23 18:57:45 2009 +0100 @@ -110,10 +110,15 @@ */ function noderef_view_alter_item(&$form, $key, $field) { if (is_array($field) && $field['type'] == 'nodereference') { - list($link, $id) = _noderef_view_get_link($field); + $link = _noderef_view_get_link($field); if (!empty($link)) { - $form[$key]['#prefix'] .= "'. $form[$key]['#suffix']; + $suffix = $link; + if (isset($form[$key]['#suffix'])) { + $form[$key]['#suffix'] = $suffix . $form[$key]['#suffix']; + } + else { + $form[$key]['#suffix'] = $suffix; + } return TRUE; } } @@ -128,7 +133,6 @@ * - Une chaine vide sinon */ function _noderef_view_get_link($field) { - static $id = 0; $path = ''; // Check if there's a view associated with this field if (isset($field['advanced_view']) && $field['advanced_view'] !== '--') { @@ -139,22 +143,19 @@ if (is_array($display->display_options) && isset($display->display_options['path'])) { $path = $display->display_options['path']; - break; + break; } } } // If we found a view with a suitable display, then link to it if (!empty($path)) { - $id++; popups_add_popups(); $options = array( - 'attributes' => array( - 'class' => 'popups noderef_view_link', - 'rel' => 'noderef_view_link_'. $id), + 'attributes' => array('class' => 'popups noderef_view_link'), 'query' => array('destination' => 'node') ); $path = l(t('Search'), $path, $options); } - return array($path, $id); + return $path; }