[Seaside] Re: How to change callback for html select on the fly

Robert Sirois watchlala at hotmail.com
Sun Aug 19 17:22:59 UTC 2012


I think more fundamentally speaking, you're not actually wanting to modify the callback, you're trying to modify the list, right? The callback doesn't care what it's sending (or shouldn't).
If you're trying to update the select element options from server data, you can easily handle that in the ajax success callback. If you're changing the options based on some client-side JavaScript, you could insert that function or use Seaside's JavaScript utilities to accomplish the same thing.
ie. (using jQuery)var figureOutNewListOptions = function() {    // some function    // OR    $.get('http://www.mydata.com/getdata', function( data ) {        // clear current options        $('selectField').html('');        ( var i = 0; i < data.records.length; i++ ) {
            $('selectField').append('<option name='+data.records[i]+'value='+data.records[i]+'>'+data.records[i]+'</option>');        }    });}var updateList = function() {    var userInput = $('#userInputTextField').val();    // validate    figureOutNewListOptions();}
Wow, that's a painful example but I hope it helps. Sorry for not writing it in Smalltalk lol.Hope that helps... I haven't had a change to touch Seaside lately :( JavaScript has taken over my life. Suck.
RS
> To: seaside at lists.squeakfoundation.org
> From: squeakman at gmail.com
> Date: Sun, 19 Aug 2012 12:53:16 -0400
> Subject: [Seaside] Re: How to change callback for html select on the fly
> 
> On 19/08/2012 10:24 AM, Bob Arning wrote:
> > Why not just make the original callback sufficiently generic that it can
> > cope with the change?
> >
> > html text: 'Choose Amount'.
> >          (html select)
> >          id: #prices;
> >          callback: [:v | self doWhateverIsImportantNowWith: v];
> >          list: #(30 50 60).
> >
> > Cheers,
> > Bob
> >
> 
> The problem with this proposed solution is that the list of choices #(30 
> 50 60) does not change on the fly.  What I want is to change the list of 
> choices, the dropdown list, on the fly.
> 
> When the user exits the text field, depending on the contents of the 
> text field, the choices are modified.  In my code example, it switches 
> from #(30 50 60) to #(15 25).
> 
> I hope this further clarifies what I am trying to do.
> 
> I appreciate your feedback.
> 
> Thanks,
> 
> Frank
> 
> 
> _______________________________________________
> seaside mailing list
> seaside at lists.squeakfoundation.org
> http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
 		 	   		  
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.squeakfoundation.org/pipermail/seaside/attachments/20120819/aedacf9c/attachment-0001.htm


More information about the seaside mailing list