Hi David, Thanks for your reply - I'll have a go at defining the function through Exhibit.
Cheers, Simon On Fri, Feb 20, 2009 at 5:44 PM, David Huynh <[email protected]> wrote: > > Simon, > > You'd need to define the function through Exhibit like so > > Exhibit.Functions["buildURL"] = { > f: function(args) { > var set = new Exhibit.Set(); > var valueType = null; > > var startDate, endDate, ...; > args[0].forEachValue(function(v) { startDate = v; return > true; }); > args[1].forEachValue(function(v) { endDate = v; return true; }); > ... > var url = ...; > > return new Exhibit.Expression._Collection([ url ], "text"); > } > }; > > Another way to do this would be > > <div ex:role="lens" ex:onshow="prepareLens"> > ... > <a ex:startDate-content=".startDate" > ex:endDate-content=".endDate" > ... > >...</a> > </div> > > with > > function prepareLens(elmt) { > var a = ... code to locate <a> from elmt ... > var startDate = a.getAttribute("ex:startDate"); > var endDate = a.getAttribute("ex:endDate"); > ... > var url = ...; > > a.href = url; > } > > David > > [email protected] wrote: > > Hi, > > > > I'm wondering if anybody can tell me if it's possible to call a > > javascript function as the argument of the ex:href-content attribute > > (or any other attribute) in an Exhibit lens? > > > > What I'm trying to do is use some Exhibit date and time parameters > > which are specified in my JSON file (e.g. .startDate, .startTime, > > endDate, endTime) and pass these to the javascript function to > > generated a URL which encodes these values, and return the URL from > > the javascript function as the value of the ex:href-content attribute > > e.g. > > > > > > <a ex:href-content="buildURL(.startDate,.startTime,.endDate,.endTime)" > > ex:content="Link Title"></a> > > > > > > where the function buildURL is declared something like as: > > > > > > function buildURL(startDate,sTime,eDate,eTime) { > > // do some string manipulation of the four parameters here and build > > a URL > > return URL; > > } > > > > > > I've tried this but it's not working for me. I'm not able to share a > > link to my Exhibit page as it's on a private network. Can anybody > > offer any guidance? Do I need to declare the > > javascript function somewhere in the Exhibit code, or can it just be > > declared within <script> tags elsewhere on my page. > > > > Thanks in advance, > > > > Simon > > > > > > > > > > -- Simon McArthur [email protected] +353 (0) 85 752 1503 --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
