Thanks Larry, I totally agree with your inputs (the first solution is always very dirty because you tried and tried things until something worked.....)
and as you probably guessed I cannot override the original link from server side, because I have no control of it, what I am doing is actually to wrap your GREAT api into some useful and common operations our developers may need. Thanks a lot (again) On Apr 5, 7:46 pm, Larry Kluger <[email protected]> wrote: > Clever.... > > A couple of notes: > 1) You're changing the link attribute from your data set. You can probably > also change the attribute (if you want to) on your server--within the > original data. > 2) Since you're munging the private attribute _link, really no need to use > the getter function since its job is to (nominally) hide the private > attribute. > So you could also do: > > var origLink = evt._link; > if(origLink != null && origLink.indexOf("myFunc") <0){ > > evt._link = "javascript:myFunc('" + origLink + "')"; > } > > 3) You're using the filter matcher code as a way to iterate through all of > the event objects. But the filter matcher is being called over and over again > for ALL of the events, not once per event. -- The filterMatcher is called, > for every event, each time the painter starts a paint cycle. > > So a better way would be to iterate through the events *once*, using your own > event iterator instead of doing it as a part of the filterMatcher: > > var eventSource = timeline.getBand(0).getEventSource(), > iterator = eventSource.getAllIterator(); > > while (iterator.hasNext()) { > var evt = iterator.next(); > > var origLink = evt.getLink(); > if(origLink != null){ evt._link = "javascript:myFunc('" + origLink > + "')";} > > } > > HTH, > > Larry > > ________________________________ > From: ora <[email protected]> > To: SIMILE Widgets <[email protected]> > Sent: Sunday, April 5, 2009 3:00:40 AM > Subject: Re: overriding the click on link behavior > > I think I found some kind of solution without changing the bubble > behavior but only the _link feild. > What I did is in the filter function changed the "_link" field to > something like javascript:myFunc(_link). > > Here is the code,: > > //the filter method > filterMatcher = function(evt) { > //debugger; > ........ > var origLink = evt.getLink(); > if(origLink != null && origLink.indexOf("myFunc") <0){ > > evt._link = "javascript:myFunc('" + origLink + "')"; > } > ........ > }; > > //and here is the function itself that was inserted to the link: > var myFunc = function(link) { > //debugger; > alert("myFunc received the link: "+link); > } > > let me know what you think of this solution.... > > Thanks > On Apr 5, 8:54 am, ora <[email protected]> wrote: > > > Hi Larry, > > > The problem is that the href that are created by the Simili in the > > bubble do not have an id. So the only way I see is to override the > > entire showBubble and add the link an id that can be referenced for > > the onClick. > > > I dont like this idea very much because it means I override the > > showBubble action in a very specific way that would probably have to > > change with every version upgrade I do. > > > Do you think otherwise, is there a nicer solution I am missing? > > > Thanks > > > Larry Kluger wrote: > > > HiOra, > > > > Add an onclick listener to the "a" element (the link) and change the href > > > attribute to > > > You can google for this type of Javascript help. > > > > Here's how I do it in one of my scripts: > > > Note: this is a private object that holds all of the functions and data > > > of the script. > > > > this.dom = dom: YAHOO.util.Dom; // I use YUI, others use jQuery, > > > or Prototype or .... > > > a_el = this.dom.get(my_id); // my_id is the id of the "a" element > > > a_el.href = 'javascript:void(0);'; // reset the href > > > > YAHOO.util.Event.addListener(a_els "click", this.on_click, my_id); > > > // this.on_click is the callback function that is invoked when the user > > > clicks on the link, > > > } > > > > If the link is within a Timeline bubble, then you'll need to create the > > > bubble's content yourself. > > > > If you want the special action to happen instead of the bubble being > > > shown, then the easiest way would be to overload the show bubble function > > > -- have it either do something special or show the bubble, depending on > > > the event's details. > > > > Larry > > > > ________________________________ > > > From:ora<[email protected]> > > > To: SIMILE Widgets <[email protected]> > > > Sent: Thursday, April 2, 2009 11:21:24 AM > > > Subject: overriding the click on link behavior > > > > Hi, > > > > I dont know if this is an easy one but.... > > > I want that everytime the link of a certain event is clicked to do my > > > own action, e.g run some kind of javascript for opening this url in a > > > special format (instead of really opening the url in a new browser). > > > > know of a nice way to do it? > > > > Thanks --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "SIMILE Widgets" 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/simile-widgets?hl=en -~----------~----~----~----~------~----~------~--~---
