On Oct 29, 4:26 pm, "Ted Gifford" <[EMAIL PROTECTED]> wrote:
> On Wed, Oct 29, 2008 at 6:35 AM, Martin S. <[EMAIL PROTECTED]>wrote:
>
>
>
> > > It's better than adding IDs, at least for my aesthetics.
> > In this example it will work even for multiple tags blocks in the same
> > HTML page because an event is used which gets the 'this' pointer,
> > but imagine that you want to set ONE specific div, which wont cause
> > any event to occur?
> > One specific, not ALL of the same class! Hey, there you need an ID,
> > that's the reason they exist.
>
> > To give you more details:
> > I'm using jQuery, but only to connect multiple onload and onunload
> > functions.
> > I'm needing getElementById because I need the handle in order to call
> > a lot of JavaScript methods on it.
> > I could maybe get this handle also with jQuery, but it would need an
> > also an ID - and would probably call getElementById by itself.
> > All browsers which can handle the rest of the JavaScript also can
> > getElementById, so there is no need to use an compatibility wrapper
> > around it.
>
> From a purely technical standpoint, I remain unconvinced. The differences
> between your macro instances are their arguments and their position within
> the page. All of this data should be easily available without IDs. But I'm
> probably still missing something.
Imagine two macro calls resulting in two `div` tags injected:
<div class="foo" id="foo-1"> ... </div>
<div class="foo" id="foo-2"> ... </div>
Please tell me how to call some dynamic JavaScript methods on, and
only on, the first div "foo-1" without the ID?
Just e.g. change the background of "foo-1" to yellow, which I think
would be
$("#foo-1').css({"background":"yellow"})
using jquery and an ID.
However I need to do somehing like this:
a = GetElementById("foo-1");
b = new SomeClassWhichNeedsAnElement(a);
b.doSomething();
To be specific: I'm using the div as container for a Google Map using
their javascript API,
and there could be two different (or identical) maps on one wiki page.
Both div's are in the same parent div, so you can't identify them
using the hierarchy.
Are you talking about some CSS expression which would say:
"In div.wikipage the n-th div.foo child", i.e. something like
"div.wikipage div.foo:nth-of-type(1)" ??
Anyway the javascript code I use needs the element as object, e.g.
some GetElementByXXXX function.
IMHO the (only) reason CSS IDs exist is to identify one unique tag in
the HTML source. So there should be preferred for this.
> In any case, I think your solution of incrementing from 1 for each request
> suffers a race condition. From a recent post on the trac-dev list by Remy
> Blank:
>
> > But Components are *not* singletons. There is exactly one instance of
> > each Component *per ComponentManager*, so in the case of Trac, *per
> > environment*.
>
> So we don't have singletons, but for a single environment, it is effectively
> so. The (hypothetical) race condition happens when two or more requests are
> received at the same time. After the first request starts processing, the
> second request could reset the counter to 1. Even without the reset, there
> still might be a race condition, although less likely.
Mmm, interesting, I see your point.
Do you think I could attach a counter on the request then?
I assume now that the `req` object in unique for every request.
If you like to have a look at my code:
http://trac-hacks.org/wiki/GoogleMapMacro#Source
Best Regards,
Martin
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Trac
Users" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/trac-users?hl=en
-~----------~----~----~----~------~----~------~--~---