(only) slightly less ugly than polling, but note that there is an event that fires when the collection of items changes, to which you could bind a check for empty facet.

in scripts/data/collection.js you can invokethe collection's "addListener" on the "onItemsChanged" property. Note that the event is fired _after_ the set of items has been updated (see "onFacetUpdated"), so it's a safe time to check for the empty facet.

Another option, which might satisfy your boss, would be to enable the "showMissing" attribute in the facet. Then the facet would never be empty. After all, if the facet is empty, it isn't because there are no items, but because every remaining item has no value for the facet.


On 11/8/2011 6:30 PM, Ryan Lee wrote:
Hi Paul,

Sorry to hear you have such rigid constraints.

Polling is an ugly solution, but if you must.  You can use jQuery and
the native setTimeout method to keep checking to see if your facet DOM
container (use Firebug to find it) contains no children and hide/unhide
accordingly.  You should be able to write conditionals to bail if
Exhibit hasn't been set up yet (check if window.exhibit is defined),
just let setTimeout keep polling for you until Exhibit is properly
instantiated.

I'm contemplating including an event hook in Exhibit 3 for this use, but
I'm not sympathetic to the idea of arbitrary hiding in the UI.  Then
again, it could be more generally useful, and Exhibit creators will have
to decide for themselves how to not disorient their users.

On 11/8/11 01:05 , Paul Warner wrote:
Thanks for the info, Ryan!  I appreciate your argument about the empty
facet providing the user with information, however, my boss does not agree,
and he would prefer that it disappear when empty.  :-(  Also, I selected
the empty example, because that is what I need to change.  I include an
example with data below.

I prefer not to mess with the list-facet.js file, if possible.  How can I
poll for the facet dom object?  I tried inserting an id in the div, so I
could access it with jquery, but jquery fails to pick up any content ever
(it seems to execute too early -  the console.log appears way before the
page loads).

Here is an example with data in the list facet:
http://www.hucompute.org/publikationen
And here is an example with NO data in the list facet:
http://www.hucompute.org/team/mitarbeiterinnen/publikationen-gleim?Itemid=4



On Mon, Nov 7, 2011 at 9:09 PM, Ryan Lee<ryan...@zepheira.com>  wrote:

There isn't a built in method.  Is there a reason in your example that
facet is there?  The property doesn't appear in the data at all.

There is probably a way to do this by rewriting the facet code, but it's
not always good UI design to just hide elements, especially when an
empty facet is useful information (that is, after successive filtering,
it is useful to some to know that no property data exists for items that
match the filters).  You would instead have to remember what was there
and that it's gone if it auto-hid.

You could look in Exhibit.ListFacet.prototype.update as a method to
rewrite for your purposes; you would have to rewrite each update for
every Facet class that pertained for it to work correctly.

http://api.simile-widgets.org/exhibit/2.2.0/scripts/ui/facets/list-facet.js

If you don't want to mess with Exhibit internals, you could instead
write something that polled or watched the facet DOM for evidence that
it was empty and hide / unhide based on that.

On 11/3/11 01:34 , Paul Warner wrote:
Hi,

I have a facet that is empty sometimes, and when it is, I would like to
hide it.  I have searched this list, and found

http://groups.google.com/group/simile-widgets/browse_thread/thread/9b132e9b525e1aca/b07c5be97ba55786?hl=en&lnk=gst&q=hide+facet#b07c5be97ba55786
But it does not seem to have the answer, or I have not understood it.  Is
there a way to hide an empty facet?


http://www.hucompute.org/team/mitarbeiterinnen/publikationen-gleim?Itemid=4
Notice the empty facet at the top right, "Special Note".

Thanks for any help!!

Regards,
Paul

--
You received this message because you are subscribed to the Google Groups
"SIMILE Widgets" group.
To post to this group, send email to simile-widgets@googlegroups.com.
To unsubscribe from this group, send email to
simile-widgets+unsubscr...@googlegroups.com.
For more options, visit this group at
http://groups.google.com/group/simile-widgets?hl=en.



--
You received this message because you are subscribed to the Google Groups "SIMILE 
Widgets" group.
To post to this group, send email to simile-widgets@googlegroups.com.
To unsubscribe from this group, send email to 
simile-widgets+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/simile-widgets?hl=en.

Reply via email to