[Seaside] something like #callback:value: but for #html: ?
Paul DeBruicker
pdebruic at gmail.com
Thu Jun 30 11:22:47 UTC 2011
On 06/29/2011 10:55 PM, Esteban Lorenzano wrote:
> Hi,
> I'm trying to fill an JQAccordion when user opens it, and I think the way to do that is by doing something like this:
>
> html div
> script: (
> html jQuery new accordion
> active: self selectedIndex - 1;
> autoHeight: false;
> onChangestart: ((html jQuery new
> alias: 'ui';
> access: 'newContent';
> call: 'load' with: (html jQuery ajax
> html: [ :renderer | renderer text: 'TEST' ];
> fullUrl))
> asFunction: #(event ui)));
> with: [
> html div id: 'header1'; with: 'header1'.
> html div.
> html div id: 'header2'; with: 'header2'.
> html div ]
>
> this example is working fine, but I'm always rendering 'TEST'. I need to discriminate which content I need to render, so I need the header id value. Using #callback:value I would call something like:
>
> ((html jQuery ajax
> callback: [ :v | "Some code here" ]
> value: (html jQuery new
> alias: 'ui';
> access: 'newHeader';
> call: 'attr' with: 'id'))
> asFunction: #(event ui))
>
> but I don't have nothing similar with #html: .
>
> of course, I can call first a callback who sets the "current header", then make an ajax call, but that's not efficient (two calls instead one).
> so, I would like to have something like #html:value:
>
> does anybody knows how can I solve this problem?
>
> thanks,
> Esteban
>
You can use an anchor for the 'header' rather than a div and have its
onClick event get content for the sibling div. You wouldn't need the
onChangestart: call.
The demo on the jQuery UI Accordion demo page uses anchors as the headers.
Something like this should work:
html div
script: (
html jQuery new accordion
active: self selectedIndex - 1;
autoHeight: false;
with: [
html anchor onClick ((html jQuery id: 'div1')) load html:[:h | self
renderDiv1ContentOn: h]; with: 'header1'.
html div id: 'div1'.
html anchor onClick ((html jQuery id: 'div2')) load html:[:h | self
renderDiv2ContentOn: h]; with: 'header2'.
html div id: 'div2'. ]
More information about the seaside
mailing list