On Tue, Oct 28, 2008 at 5:16 AM, Martin S. <[EMAIL PROTECTED]>wrote:

>
> On Oct 28, 2:44 am, "Ted Gifford" <[EMAIL PROTECTED]> wrote:
> > Random number, perhaps?
> http://www.python.org/doc/2.5.2/lib/module-random.html
> A random number is much less unique than a incremented number, because
> you have
> the chance - even if it's a very small one - that you get the number
> twice.
>
> > I'm wondering if you actually need the ID, or if it just makes it more
> > convenient to write some javascript or something. How do you use it?
> I need the ID for javascript, in order to call getElementById on it.
> Because the macro could get used twice on the same wiki page I need
> unique IDs.
>
> I now implemented it with a class integer variable which gets
> incremented every time the macro is called - which works ok so far.
> Because it isn't reset (as long trac isn't restarted) there might be
> in theory an overrun after a long runtime, which should be ok.
>

For the devil's advocate in me: If that risk is okay, have you calculated
the risk of duplicate random numbers? It's probably just as small, .... or
hold that thought, this is python so I think integers grow pretty much
without bound (where your use case is concerned).
But again, I'm not sure why you need to use getElementById. Trac ships with
jQuery, which allows you to scope things very nicely, e.g.

jQuery('.someContainerOfMyMacroClass .trigger').click(function(){
  jQuery(this).parent().append("<p>You clicked the trigger</p>");
});
..........
<div class="someContainerOfMyMacroClass">
  <a class="trigger" href="#">Click me!</a>
  <!-- <p>You clicked the trigger</p> shows up here -->
</div>

It's better than adding IDs, at least for my aesthetics.

Ted




-- 
          +                       -

--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to