[Freebase-discuss] suggest - possibility of registering a callback to run when elements are injected?
michael dungan
michael at tennmandigital.com
Tue Mar 23 20:22:07 UTC 2010
Dae Park wrote:
> Would this not work?
>
> @import url("http://freebaselibs.com/static/suggest/1.0.3/suggest.css")
> .fbs-pane,
> .fbs-flyout-pane {
> z-index: 10000 !important;
> }
>
> or is it that you do not want to serve your own css? If this is the case
> and is just a z-index issue, we may be able to put a z-index option in
> suggest. I am a little hesitant on creating some generic callback on
> every suggest element created. I wonder if jQuery has some kind of live
> event binding for element creation...hmmm?
This is my current solution, but yeah I'd prefer not to have to serve my
own CSS, as we would eventually like to make it possible for the client
to set their own styles for the widgets we embed into their site, which
the suggest panes are part of. In that case, having to serve separate
CSS files, whether pre-generated or not, for each client starts to feel
onerous and wrong. I'd rather be able to style elements directly in JS
based on their saved style preferences (which we would just pull from
our server as JSON.)
The only reason I asked about the more generic solution was because I
figured it would be useful to a wider number of users.
Looking at the jQuery source, I see no events being triggered when
elements are created and injected via it (looking at jQuery.fn.init for
this).
One thing jQuery does offer, however, is the ability to pass in a config
object when creating elements via strings (see
http://api.jquery.com/jQuery/#jQuery2 ), which if exposed would also
solve my problems. Unfortunately this only works with jQuery 1.4 and
later, so it may be no good for you.
>
> Anyhow, thank you for bringing this up and I am sure others will run
> into this z-index issue. We will try to get out a fix. In the meantime,
> will the above work as a temporary solution?
Yep, this works for now, but I want to take it even further ;)
-mpd
>
> -dae
>
> On Mar 22, 2010, at 5:40 PM, michael dungan wrote:
>
>> Dae Park wrote:
>>> We've done our utmost to prefix all of the suggest css identifiers
>>> ("fbs-") so that they do not conflict with other existing styles. In
>>> fact, you can further ensure the identifiers with the "css_prefix"
>>> option. It is feasible to inline all styles but it was our intention
>>> from the beginning that others would have the ability to theme the
>>> suggest elements by just providing their own css.
>>
>> My case is slightly different. I'm working on http://stippleit.com and
>> we would like to use suggest for the client-side dot creation. I have
>> everything working currently, except that the z-index of the popup forms
>> is set to 'auto', and I want to explicitly set it without having to
>> maintain my own copy of the stylesheet. The z-index is the ONLY thing I
>> need to tweak.
>>
>>>> it's poor web citizenship for us to be injecting
>>>> extra stylesheets
>>>
>>> I think this can go both ways. Would you rather see a big mess of inline
>>> styles (when you view source/inspect element) or a simple link to an
>>> external stylesheet that lists all the rules. Anyhow, sites must have a
>>> lot of trust for them to inject your javascript. That goes without
>>> saying, they probably trust your javascript to do the right thing and
>>> IMHO, I don't really see the harm in dynamically inserting a link to an
>>> external css, which btw is 5 lines of code:
>>>
>>> var link = document.createElement('link');
>>> link.setAttribute("rel", "stylesheet");
>>> link.setAttribute("type", "text/css");
>>> link.setAttribute("href", "${url}");
>>> document.getElementsByTagName("head")[0].appendChild(link);
>>>
>>
>> This is what I'm doing already and I dislike it immensely. Seeing inline
>> styles when I look at the source is not problematic to me. That's not
>> the real issue I have, though.
>>
>> The original problem I wanted to solve in the end is just to be able to
>> easily set the z-index of created popups so they aren't showing up
>> underneath the toolbar.
>>
>> -mpd
>>
>>>
>>>
>>> -dae
>>>
>>>
>>> On Mar 22, 2010, at 3:07 PM, michael dungan wrote:
>>>
>>>> Hi,
>>>>
>>>> We are looking to use suggest in a project of ours, but because we are
>>>> using it in code that will run on a client's site (i.e. they will be
>>>> linking to our script,) it's poor web citizenship for us to be injecting
>>>> extra stylesheets into client-side pages. The elements created for
>>>> suggest, however, are not directly styleable in javascript that I am
>>>> aware of (outside of silliness like firing a callback at set intervals
>>>> to look for new suggest elements,) and new ones are created and injected
>>>> into the DOM every time one would be needed, instead of caching and
>>>> reusing.
>>>>
>>>> The easiest solution I can see right now is just allowing registration
>>>> of a callback that fires anytime an element is injected into the DOM by
>>>> suggest.
>>>>
>>>> Is this a worthwhile feature?
>>>>
>>>> Is there another way to do what I want that is possible right now
>>>> (outside of pulling in stylesheets over the network or polling with
>>>> timers, of course)?
>>>>
>>>> thanks,
>>>>
>>>> -mpd
>>>>
>>>> _______________________________________________
>>>> You are receiving this message because you are subscribed to the
>>>> Freebase-discuss mailing list.
>>>> To post a message to the list: Freebase-discuss at freebase.com
>>>> <mailto:Freebase-discuss at freebase.com>
>>>> <mailto:Freebase-discuss at freebase.com>
>>>> To unsubscribe, view archives, etc:
>>>> http://lists.freebase.com/mailman/listinfo/freebase-discuss
>>>
>>>
>>> ------------------------------------------------------------------------
>>>
>>> _______________________________________________
>>> You are receiving this message because you are subscribed to the
>>> Freebase-discuss mailing list.
>>> To post a message to the list: Freebase-discuss at freebase.com
>>> <mailto:Freebase-discuss at freebase.com>
>>> To unsubscribe, view archives, etc:
>>> http://lists.freebase.com/mailman/listinfo/freebase-discuss
>>
>> _______________________________________________
>> You are receiving this message because you are subscribed to the
>> Freebase-discuss mailing list.
>> To post a message to the list: Freebase-discuss at freebase.com
>> <mailto:Freebase-discuss at freebase.com>
>> To unsubscribe, view archives, etc:
>> http://lists.freebase.com/mailman/listinfo/freebase-discuss
>
>
> ------------------------------------------------------------------------
>
> _______________________________________________
> You are receiving this message because you are subscribed to the Freebase-discuss mailing list.
> To post a message to the list: Freebase-discuss at freebase.com
> To unsubscribe, view archives, etc: http://lists.freebase.com/mailman/listinfo/freebase-discuss
More information about the Freebase-discuss
mailing list