[Seaside] Re: Q on "html select" and how to get selected item in an Ajax callback

John McKeon p3anoman at gmail.com
Thu Oct 13 15:55:01 UTC 2011


Well, if you want to re-render the page, you can just send beSubmitOnChange
to the select tag.


On Thu, Oct 13, 2011 at 11:44 AM, squeakman <squeakman at gmail.com> wrote:

> Thanks Bob and John,
>
> I have done as you suggested and it does work.
>
> Here is what the my code now looks like:
>
> (html select)
>  id: 'stocksList';
>  list: self listOfStocks;
>
>  " Ajax Callback 1 "
>  onChange: (html scriptaculous request
>     triggerForm: (html scriptaculous element up: 'form'));
>
>  "Ajax Callback 2"
>  onChange: (html scriptaculous evaluator callback: [:s | s refresh]);
>
>  "non Ajax Callback "
>  callback: [:selStock | self selectedStock: selStock]
>
>
> If I understand things correctly, on change causes "Ajax Callback 1" to be
> called which causes "non Ajax Callback" to be called where the selected
> stock is updated.
>
> This works but I also want to re-render the page without having to use a
> Submit button. I thought that the "non Ajax Callback" would have caused the
> entire page to be re-rendered but that does not happen.
>
> The "Ajax Callback 2" forces the re-rendering of the page.
>
> One last question to wrap this up: "Is this the prescribed way to do this
> task?".
>
> Thank you very much,
> Frank
>
>
>
>
>
> On 13/10/2011 10:40 AM, John McKeon wrote:
>
>> I would add that to get the callback to occur via AJAX add:
>> onChange: (html jQuery ajax serializeThisWithHidden)
>> And in an attempt to make it clearer:
>> The parameter in the list: message is a collection of *objects* and the
>> callback :value will be the selected object. If you give it a collection
>> of string representations of your Stock objects, you will get back the
>> selected string representation. But if you give it a collection of
>> Stocks in this case, you will get back the selected Stock object.
>> Seaside handles the bookwork for you in determining which object in the
>> collection was selected. You don't need to deal with the selected index
>> if you don't want to.
>>
>> On Thu, Oct 13, 2011 at 10:16 AM, Bob Arning <arning at charm.net
>> <mailto:arning at charm.net>> wrote:
>>
>>    We had a very similar question on 28-29 Sept (see "Using the select
>>    tag"). The end result was something like:
>>
>>    (html select)
>>         list: self genders;
>>         selected: self contact gender;
>>         enabled: [:ea | ea notNil];
>>         labels: [:ea | ea ifNil: ['---'] ifNotNil: [ea printableVersion]];
>>         callback: [:value | self contact gender: value].
>>
>>    Cheers,
>>    Bob
>>
>>
>>
> ______________________________**_________________
> seaside mailing list
> seaside at lists.**squeakfoundation.org <seaside at lists.squeakfoundation.org>
> http://lists.squeakfoundation.**org/cgi-bin/mailman/listinfo/**seaside<http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.squeakfoundation.org/pipermail/seaside/attachments/20111013/7e66d83e/attachment.htm


More information about the seaside mailing list