I'm not 100% sure what you mean but here's how I might do it.
Make just one copy of <script> inside <head>, don't put it in the lens
template:
<script>
function changeGraphPeriods(select) {
var period = select.value;
var img = document.getElementById(select.getAttribute("image"));
...
}
</script>
In the lens template:
<select ex:image-subcontent="image-{{.graphUtil}}"
onChange="changeGraphPeriods(this);">
...
</select>
<img ex:id-subcontent="image-{{.graphUtil}}" />
David
Li, Yee-Ting wrote:
> Hi David.
>
>
>> So, where is the <select/>? Inside each element's lens? Or just a common
>> one for the whole page? When does the user choose something in it?
>> Before you load the data? After you load the data?...
>>
>
> currently the select is defined within the lens and i load the data as per
> the examples on the webpage. the user would select something on the <select/>
> after the data loads - from within the lens. basically i would like to
> replace the img tag's src attribute a concatenation of '.graphUtil' and the
> value of the <select/>.
>
>
> <link href="/cgi-bin/exhibit.cgi?mode=port_list&device=xxx.yyy.zzz"
> type="application/json" rel="exhibit/data" />
> ...
>
> <div ex:role="exhibit-lens" class="item">
> <table>
> <tr>
> <td>
>
> <p><h2>Device <span ex:content=".node"></span> | Port <span
> ex:content=".label"></span></h2></p>
>
> <b>Alias</b>: <span ex:content=".alias"></span> <b>Peer</b>: <span
> ex:content=".peer"></span></br>
> <b>Settings</b>:
> <span ex:content=".speed"></span>mbps /
> <span ex:content=".duplex"></span> /
> <span ex:content=".port_fast"></span>
>
> <p><b>Display</b>:
> <script>
> // on change; update the uri of the graphs
> function changeGraphPeriods( period ) {
> var arg = "&period=" + period;
> // get basically does a getElementById
> my orig = get( 'graphUtil').src;
> // of course some filtering of the previous arg value will be
> required
> get( 'graphUtil' ).src = orig + arg;
> // do the same for the Error graph
>
> // this doesn't work because the html that is rendered by
> exhibit does not
> // contain the id attribute - even though it does exist in the
> lens definition
> }
> </script>
>
> <select id="period" onChange="changeGraphPeriods(this.value);">
> <option value="2d">2 days</option>
> <option value="2w">2 week</option>
> <option value="2m">2 months</option>
> <option value="1y">1 year</option>
> </select>
> </p>
>
> <p id="graphs">
> <img id="graphUtil" ex:src-content=".graphUtil"/><br/>
> <img id="graphUtil" ex:src-content=".graphError"/><br/>
> </p>
>
> </td>
> </tr>
> </table>
> </div>
>
>
> if there is another way i could do this, i'll be more than happy to try it.
>
>
> thanks!
>
> Yee.
>
> ------------------------------------------------------------------------
>
> _______________________________________________
> General mailing list
> [email protected]
> http://simile.mit.edu/mailman/listinfo/general
>
_______________________________________________
General mailing list
[email protected]
http://simile.mit.edu/mailman/listinfo/general