I wasn't sure whether to post this under jquery_ui or here, and the fact that such a fundamental bug hasn't been reported before led me to file this as a 'support request' rather than a 'bug report'. NodeReference Explorer works fine with Drupal's Javascript Optimization turned off, but when I turn it on it fails.

This is true of every version I tried, which included beta's 5 and 6, as well as the latest dev.

I also tried it with both Jquery UI 1.6 and jquery UI 1.x-dev and experienced the same results.

I've tried it with and without JQuery Update 1.1 installed.

I'm using Drupal 6.13

The real question i want to ask is: does Nodereference Explorer work with JavaScript Optimization On for anyone?

Comments

vood002’s picture

Didn't mean to sound like a dick by bolding the question... I just wanted someone scanning to get to the important part. Does NRX work for anyone with Javascript Optimization turned on?

Anonymous’s picture

Same problem, clicking "Browse" keeps loading, but no modal pops up, nothing happens. I have regular jquery from drupal, plus standard versions of the rest.

abaddon’s picture

Category: support » bug

ditto, i get this javascript error: Drupal.nodereference_explorer.actions is undefined - and context " .click(Drupal.nodereference_explorer...ss('nodereference-explorer-processed');\n"
i think it should be filled under bug reports, correct me if im wrong, if no one deals with it ill probably look to fix it in the next 2 weeks
$ grep -rn "click(Drupal.nodereference_explorer" .
./nodereference_explorer/js/explorer.actions.js:20: .click(Drupal.nodereference_explorer.actions.browse).addClass('nodereference-explorer-processed');
./nodereference_explorer/js/explorer.actions.js:23: .click(Drupal.nodereference_explorer.actions.remove).addClass('nodereference-explorer-processed');

the NRX object is undefined with only js aggregation turned on (and not caching) , why could it happen? it seems its initialized just a couple of lines above..

Anonymous’s picture

I tried the built in modal, and the modal form api for the popups, both break with javascript compression ON.

stacysimpson’s picture

Ditto. With Javascript optimization turned on and using beta6, the model dialogue opens and I can select a value. However, the selected value in modal dialog doesn't take effect. AJAX clock animation just spins forever.

bibo’s picture

Subscribing.

This module seems incredibly promising (just what I needed: Image noderefencing with Views integration). So far it seemed to be the best image-related module for my needs. Working Drupal js compression is also crucial (to my projects at least).

wojtha’s picture

Title: Optimize Javascript breaks Nodereference Explorer » Optimize Javascript (and CSS too) breaks Nodereference Explorer
Status: Active » Needs review
StatusFileSize
new11.36 KB

Hello,

there is a sligthly bigger patch for that.

Fixes:
1) Javascript optimalization
2) CSS optimalization
3) minor Javascript (LINT) fixes

Note: You need rebuild a theme cache after apllying this patch to make it working.

Javascript & CSS optimalization
========================
JS and CSS filenames cannot be parsed from the HTML document, when JS or CSS optimalization is enabled, because multiple files are aggregated into one file with a random name. So I created page preprocess hook and I capture all JS and CSS filenames which are registered via drupal_add_js() and drupal_add_css() functions. Than I store them in the Drupal.settings object (Drupal.settings.jsInit, Drupal.settings.cssInit) to make them accessible in javascript.
Later when "Browse" button is clicked and additional CSS and JS files are going to be loaded with Ajax, all files are checked if they exists in Drupal.settings "init" arrays - if filename exists in the array it is not going to be loaded.

Minor Javascript fixes
================

My IDE and also JSLint (http://www.jslint.com) reports "Missing semicolon" warnings on each closure, so I added them.

// Missing semicolon
Drupal.behaviors.NodereferenceExplorerSelection = function(context) {  
}
// Correct
Drupal.behaviors.NodereferenceExplorerSelection = function(context) {  
};

The second minor improvement is "defensive" initialization of namespaces.

Drupal.NodereferenceExplorer = {};

// Better
Drupal.NodereferenceExplorer = Drupal.NodereferenceExplorer || {};
gnindl’s picture

On fields with multiple values I receive

Drupal.settings.cssInit is undefined /sites/default/modules/nodereference_explorer/js/explorer.js?X Line 74

Seesm that the css files are not added correctly.

wojtha’s picture

StatusFileSize
new13.66 KB
new14.81 KB

Hi gnidl,

I have also multiple field with multiple values, but I can't reproduce the error. I remember I got this error during development of the patch, but I fixed it. For me everything working smoothly (FF 3.5, IE 8). Only error which I get sometimes after closing modal window is "handler is undefined" JS error, but this error I get also with unmodified Beta6, so it isn't caused by "my" code.

Line 74 in explorer.js is a nonsens - in my patched file I have a comment on this line.

I'm sending another patch. And also all changed files in archive to make sure that bad patch doesn't screw it :-)

gnindl’s picture

Sorry, I don't get it, maybe you have a different setup.

Mine is:
Drupal 6.12
jquery_ui 1.3
jQuery UI 1.6 (with jQuery 1.2.6)
Firefox 3.5.5

I don't use jquery_update.

@wojtha: What do you use?

wojtha’s picture

@gnidl:

Drupal 6.14, built-in jQuery 1.2.6, jQuery UI 1.3 with 1.6 UI lib

Windows Vista 32bit
Firefox 3.5.5
Internet Explorer 8

vood002’s picture

I tested earlier today, and was still receiving an error almost exactly as described in #5. I applied the patch_2 from #9 and it is now working with javascript optimization turned on.

Great work guys~I'll continue to test and make sure everything is working

vood002’s picture

Version: 6.x-1.1-beta6 » 6.x-1.1-beta7
Status: Needs review » Reviewed & tested by the community

I've tested again today with beta7, and NRX continues to not function with optimization turned on. Upon applying this patch, NRX functioned correctly. I've changed the status to 'reviewed and tested by the community'

andylin12’s picture

I met the "cssInit undefined" issue when applying the patch with Drupal 6.13.
But the issue get fixed after I empty the cache in the performance setting and everything went fine.

Hope that helps.

omerida’s picture

StatusFileSize
new11.63 KB

patch in #9 didn't work for me. I don't think you can simply manipulate the array you get from drupal_add_js() and drupal_add_css() and expect your changes to persist through later preprocess functions. Those two functions keep an internal array with js and css data, so you have to use them.

I re-rolled a patch that works for me and also removed a .buildpath and .project file inadvertently included in the same patch. Nodereference explorer is working for me now.

My setup - Drupal 6.13, NRX 6.x-1.x-dev

I also have Lightbox2 installed, jquery ui 1.6, and jquery update to 1.2.6

gnindl’s picture

Version: 6.x-1.1-beta7 » 6.x-1.x-dev
Assigned: Unassigned » gnindl
Status: Reviewed & tested by the community » Needs review

The patch of #15 has been reviewed, used as a working base and further developed. Check out the current dev snapshot for further testing.

jasonawant’s picture

latest dev snap shot is working with css and js optimization enabled.

gnindl’s picture

Version: 6.x-1.x-dev » 6.x-1.1-rc1
Status: Needs review » Fixed

Patch included in the release candidate

Status: Fixed » Closed (fixed)

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