When more than JavaScript widget is placed onto a page, only the widget furthest down the page is displayed. For example in the header of the page external to Drupal we need a an urgent notices widget and in the body of the page we need a list of courses from a certain subject area. Only the widget in the body displays because it comes after the widget in the header. Thanks for your help.

Comments

danieldd’s picture

Just to confirm that I have also experienced this issue. Using version 6.x-1.1

BenK’s picture

Subscribing...

Ian Ward’s picture

Status: Active » Needs review
StatusFileSize
new6.44 KB

Attached is a patch that determines a widget ID based on the views name and current display. The patch also makes it possible to specify an ID if using the web_widgets API directly as opposed to via views.

The problem with the javascript is that it cannot handle placing the iframe into the correct area on the dom because web widget id's are usually the same. Web widget ids are usually the same because the current code only differs the ID if the embed code is rendered on a page for more than one widget at a time (on the Drupal side).

Fixing the javascript could be an alternative to this patch so that it:

* uses a class instead of an ID since duplicate IDs on the dom has undefined behavior.
* gets all the classes which are "web_widget" and adds the iframe to the first it finds, along with concats a 'processed' class to that element
* next time the script runs for widget #2 it should only find the first "web_widget" class without the "processed" class.

This is easier with jquery but is likely more work without jquery at hand, which is the reality.

Ian Ward’s picture

StatusFileSize
new7.4 KB

Don't roll patches on an empty stomach. New patch attached which fixes a couple parts I missed w/ the first.

Ian Ward’s picture

StatusFileSize
new7.38 KB

New patch now that http://drupal.org/node/589724 is committed.

Ian Ward’s picture

StatusFileSize
new2.4 KB

Attached is a patch with a simpler solution and no interface changes. The widget id is calculated with md5(microtime()).

Ian Ward’s picture

Status: Needs review » Fixed

Committed this here http://drupal.org/cvs?commit=385740 ... marking as fixed.

Status: Fixed » Closed (fixed)

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