Hello List,
I am trying to learn how to use jQuery. I have the following simple example but the callback is never triggered when I hit the submit button. I have included the JQuery library in my configuration. Can you tell me what is wrong? renderContentOn: html html form with: [html label with: 'Name'. (html textInput) id: #temp; value: 'sample text'. html submitButton onClick: (html jQuery ajax callback: [:v | self halt] value: (html jQuery: #temp) value)] With Thanks, Frank _______________________________________________ seaside mailing list [hidden email] http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside |
I don't know why your example doesn't trigger. If you're trying to submit the form when clicking on the button, this should work (provided you create the input fields properly with callbacks, e.g. with #on:of)
html submitButton onClick: (html jQuery ajax serializeForm; script: [:s| my callback here]); with: 'Click me' rado
On Thu, Aug 23, 2012 at 10:39 PM, squeakman <[hidden email]> wrote: Hello List, _______________________________________________ seaside mailing list [hidden email] http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside |
In reply to this post by squeakman
submit buttons think *they* know what to do
with your click, but...
[snip] html button bePush; onClick: (html jQuery ajax [snip] works. On 8/23/12 4:39 PM, squeakman wrote:
Hello List, _______________________________________________ seaside mailing list [hidden email] http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside |
On 23/08/2012 5:14 PM, Bob Arning wrote:
> submit buttons think *they* know what to do with your click, but... > > [snip] > html button bePush; onClick: (html jQuery ajax > [snip] > > works. > Brilliant, it worked like a charm. Oh well, two hours wasted but a lesson learned. Thanks _______________________________________________ seaside mailing list [hidden email] http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside |
In reply to this post by Bob Arning-2
Hello Again,
The callback for the onClick works but now I am stuck on getting the callback for the button to be called - the one with the comment "non-ajax callback" in the code below. I read on the web that: "Instead put your callback code into the jQuery callback itself, aka the #script: block." This is what I am trying to do below but it failed along with a few other experiments I tried. What I want to do is trigger the form so that all the various callbacks are called. Can you offer any help with this? Thanks again, Frank ----- code follows ---- renderContentOn: html (html form) id: #form; with: [html label with: 'Name'. (html textInput) id: #temp; value: 'sample text'. (html button bePush) onClick: (html jQuery ajax callback: [:v | self halt] value: (html jQuery: #temp) value); onClick: (html jQuery ajax script: [:s | (s jQuery: #form) triggerSubmit]); callback: [self halt]; " non-ajax callback" with: 'Pay >'] _______________________________________________ seaside mailing list [hidden email] http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside |
Well, now that you have the triggerSubmit in
there, this seems to work:
renderContentOnSqueakman3: html (html form) id: #form; with: [html label with: 'Name'. (html textInput) id: #temp; value: 'sample text'. (html button beSubmit) "<=====change" onClick: (html jQuery ajax callback: [:v | self halt] value: (html jQuery: #temp) value); onClick: (html jQuery ajax script: [:s | (s jQuery: #form) triggerSubmit]); callback: [self halt]; " non-ajax callback" with: 'Pay >'] On 8/23/12 6:08 PM, squeakman wrote:
Hello Again, _______________________________________________ seaside mailing list [hidden email] http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside |
On 23/08/2012 6:53 PM, Bob Arning wrote:
> Well, now that you have the triggerSubmit in there, this seems to work: > > renderContentOnSqueakman3: html > > (html form) > id: #form; > with: > [html label with: 'Name'. > (html textInput) > id: #temp; > value: 'sample text'. > > (html button beSubmit) > onClick: (html jQuery ajax > callback: [:v | self halt] "<=== this is never called" > value: (html jQuery: #temp) value); > > onClick: (html jQuery ajax script: "<=== not needed" > [:s | (s jQuery: #form) triggerSubmit]); "<== not needed" > > callback: [self halt]; " non-ajax callback" > with: 'Pay >'] > > Yes, that does call the "non-ajax callback" but now the callback marked "<=== this is never called" above is not called. Also, it seems that with the beSubmit added, the two lines marked "<=== not needed" are not needed. I will keep plugging away at this and if I get a solution I will post it. Thanks, Frank _______________________________________________ seaside mailing list [hidden email] http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside |
Hmm...
This is getting interesting. I made these changes: renderContentOnSqueakman3: html Transcript show: 'rendering ',html requestContext request url asString; cr. (html form) id: #form; with: [html label with: 'Name'. (html textInput) id: #temp; value: 'sample text'. (html button beSubmit) onClick: (html jQuery ajax callback: [:v | Transcript show: 'on click'; cr.] value: (html jQuery: #temp) value); onClick: (html jQuery ajax script: [:s | (s jQuery: #form) triggerSubmit]); callback: [Transcript show: 'non-ajax'; cr.]; " non-ajax callback" with: 'Pay >'] and see this in the transcript as I click the pay button over and over: rendering /mt rendering /mt non-ajax rendering /mt?_s=JTe6UE1ZzC_doo3j&_k=RVMTCSGy6eRuwFPa on click non-ajax rendering /mt?_s=JTe6UE1ZzC_doo3j&_k=HrNRut8hmeMBy9u3 on click non-ajax rendering /mt?_s=JTe6UE1ZzC_doo3j&_k=mFjQlh1kqGF6357K on click non-ajax rendering /mt?_s=JTe6UE1ZzC_doo3j&_k=F0hO6ifLUdBNeIkO non-ajax rendering /mt?_s=JTe6UE1ZzC_doo3j&_k=bTdSB3mLJzUjv_Ll on click non-ajax rendering /mt?_s=JTe6UE1ZzC_doo3j&_k=lDq1GQPbcjSImBAP non-ajax rendering /mt?_s=JTe6UE1ZzC_doo3j&_k=LRsJryXuP-xaOeXJ non-ajax rendering /mt?_s=JTe6UE1ZzC_doo3j&_k=AQx9GhKhAAQkiLZe on click non-ajax rendering /mt?_s=JTe6UE1ZzC_doo3j&_k=3C3ftOy_RGEglbCC non-ajax rendering /mt?_s=JTe6UE1ZzC_doo3j&_k=_7Q2Ed4aVj6wkRYh non-ajax rendering /mt?_s=JTe6UE1ZzC_doo3j&_k=fvjjH-UmKYv9nZ3J non-ajax rendering /mt?_s=JTe6UE1ZzC_doo3j&_k=lGOYq5nlHMEUDGHk non-ajax rendering /mt?_s=JTe6UE1ZzC_doo3j&_k=r7nM6kuJy_V_12b- sometimes both are triggered and sometimes only one. Curious On 8/23/12 7:39 PM, squeakman wrote:
On 23/08/2012 6:53 PM, Bob Arning wrote: _______________________________________________ seaside mailing list [hidden email] http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside |
I don't think two click listeners can be registered like that. There can only be one #onClick() if I remember right. Try to chain the jquery calls.
RS Date: Thu, 23 Aug 2012 21:06:07 -0400 From: [hidden email] To: [hidden email] Subject: Re: [Seaside] Re: Help with JQuery example Hmm... This is getting interesting. I made these changes: renderContentOnSqueakman3: html Transcript show: 'rendering ',html requestContext request url asString; cr. (html form) id: #form; with: [html label with: 'Name'. (html textInput) id: #temp; value: 'sample text'. (html button beSubmit) onClick: (html jQuery ajax callback: [:v | Transcript show: 'on click'; cr.] value: (html jQuery: #temp) value); onClick: (html jQuery ajax script: [:s | (s jQuery: #form) triggerSubmit]); callback: [Transcript show: 'non-ajax'; cr.]; " non-ajax callback" with: 'Pay >'] and see this in the transcript as I click the pay button over and over: rendering /mt rendering /mt non-ajax rendering /mt?_s=JTe6UE1ZzC_doo3j&_k=RVMTCSGy6eRuwFPa on click non-ajax rendering /mt?_s=JTe6UE1ZzC_doo3j&_k=HrNRut8hmeMBy9u3 on click non-ajax rendering /mt?_s=JTe6UE1ZzC_doo3j&_k=mFjQlh1kqGF6357K on click non-ajax rendering /mt?_s=JTe6UE1ZzC_doo3j&_k=F0hO6ifLUdBNeIkO non-ajax rendering /mt?_s=JTe6UE1ZzC_doo3j&_k=bTdSB3mLJzUjv_Ll on click non-ajax rendering /mt?_s=JTe6UE1ZzC_doo3j&_k=lDq1GQPbcjSImBAP non-ajax rendering /mt?_s=JTe6UE1ZzC_doo3j&_k=LRsJryXuP-xaOeXJ non-ajax rendering /mt?_s=JTe6UE1ZzC_doo3j&_k=AQx9GhKhAAQkiLZe on click non-ajax rendering /mt?_s=JTe6UE1ZzC_doo3j&_k=3C3ftOy_RGEglbCC non-ajax rendering /mt?_s=JTe6UE1ZzC_doo3j&_k=_7Q2Ed4aVj6wkRYh non-ajax rendering /mt?_s=JTe6UE1ZzC_doo3j&_k=fvjjH-UmKYv9nZ3J non-ajax rendering /mt?_s=JTe6UE1ZzC_doo3j&_k=lGOYq5nlHMEUDGHk non-ajax rendering /mt?_s=JTe6UE1ZzC_doo3j&_k=r7nM6kuJy_V_12b- sometimes both are triggered and sometimes only one. Curious On 8/23/12 7:39 PM, squeakman wrote:
On 23/08/2012 6:53 PM, Bob Arning wrote: _______________________________________________ seaside mailing list [hidden email] http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside _______________________________________________ seaside mailing list [hidden email] http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside |
Robert Sirois <watchlala <at> hotmail.com> writes:
> >I don't think two click listeners can be registered like that. There can only be one #onClick() if I remember right. Try to chain the jquery calls. > I hope you don't mind me jumping into the conversation. I am also struggling with callbacks with ajax. I have an issue with your statement that 'There can only be one #onCLick(). However, the code in Dynamic Web Development with Seaside 20.4.1.Defining a Callback shows two onClick handlers being specified. _______________________________________________ seaside mailing list [hidden email] http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside |
You're right they both get called. I just made a quick example.
html div style: 'width: 300px; height: 300px; border: 1px solid black; margin: 50px;'; onClick: (html jQuery this cssAt: 'background-color' put: 'red'); onClick: (html jQuery this cssAt: 'color' put: 'blue'); with: 'Hey I''m not turning blue!!!' "oh wait, I am!" I must be thinking of something else that wasn't getting called when there were two listeners registered. Lol the answer is so obvious. I'm looking at this post (is this still the question?) http://lists.squeakfoundation.org/pipermail/seaside/2012-August/029031.html If you send #bePush to a button, it will not respond to any native behavior... here is the method comment: "Creates a push button. Push buttons have no default behavior. Each push button may have client-side scripts associated with the element's event attributes. When an event occurs (e.g., the user presses the button, releases it, etc.), the associated script is triggered." RS > To: [hidden email] > From: [hidden email] > Date: Mon, 27 Aug 2012 19:15:15 +0000 > Subject: [Seaside] Re: Help with JQuery example > > Robert Sirois <watchlala <at> hotmail.com> writes: > > > > >I don't think two click listeners can be registered like that. There > can only be one #onClick() if I remember right. Try to chain the > jquery calls. > > > I hope you don't mind me jumping into the conversation. I am also > struggling with callbacks with ajax. I have an issue with your > statement that 'There can only be one #onCLick(). However, the code > in Dynamic Web Development with Seaside 20.4.1.Defining > a Callback shows two onClick handlers being specified. > > _______________________________________________ > seaside mailing list > [hidden email] > http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside _______________________________________________ seaside mailing list [hidden email] http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside |
In reply to this post by mozillanerd
Two onClicks seem to be fine. The problem my
example was having, I think, was in using onClicks with a submit
button.
Cheers, Bob On 8/27/12 3:15 PM, intrader wrote:
Robert Sirois <watchlala <at> hotmail.com> writes:I don't think two click listeners can be registered like that. Therecan only be one #onClick() if I remember right. Try to chain the jquery calls.I hope you don't mind me jumping into the conversation. I am also struggling with callbacks with ajax. I have an issue with your statement that 'There can only be one #onCLick(). However, the code in Dynamic Web Development with Seaside 20.4.1.Defining a Callback shows two onClick handlers being specified. _______________________________________________ seaside mailing list [hidden email] http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside _______________________________________________ seaside mailing list [hidden email] http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside |
In reply to this post by mozillanerd
intrader <intrader <at> aol.com> writes:
> Thanks both for your answers. The trouble I have is with callbacks in ajax calls (using scriptaculous) I include a pastebin of a small project superimposed on the code for MyFirstComponent. The paste is at http://paste.ubuntu.com/1170727/. I am not able to get the callback in the #onChange handler for the input text box. I am not clear what the #triggerForm method is for - it may have the effect of not allowing the callback in the onChange to execute. The javascript meaning of callbacks is way overloaded in the use for seaside. Thanks for your help _______________________________________________ seaside mailing list [hidden email] http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside |
It looks like there's a few things you may or may not be doing with your code that I see. I don't necessarily have a solution for you, but maybe this will get you on the right track:
First of all, for your sanity, you may want to separate out your callback functions as separate methods. It makes the code a lot easier to follow. Also, callbacks are simply functions that can be passed around just like a variable. They're known as anonymous functions also, if that helps. They are not overused in Seaside at all. In fact, many languages use them as a core aspect of their architecture (ie. NodeJS). Callbacks should be your best friend :) They are intrinsic to any asynchronous pattern (ie. Ajax). Here's a simple example: I ask the server for something (ajax GET request). Now, I don't know when the server is going to get back to me with the answer, or if at all, but what I can provide is instructions for what to do with a successful or failed response. That's what the callback is doing for me. I don't know much about Scriptaculous, but I think you probably want the ajax request object instead of updater. There should be a way to configure updater so that you serialize the form and send that data serverside. Also, #renderTheListWith:on: doesn't need to do any rendering stuff. Your callback in the updater can deal with that. RS > To: [hidden email] > From: [hidden email] > Date: Mon, 27 Aug 2012 22:06:24 +0000 > Subject: [Seaside] Re: Help with JQuery example > > intrader <intrader <at> aol.com> writes: > > > > Thanks both for your answers. The trouble I have is with callbacks > in ajax calls (using scriptaculous) I include a pastebin of a small > project superimposed on the code for MyFirstComponent. The paste is at > http://paste.ubuntu.com/1170727/. I am not able to get the callback > in the #onChange handler for the input text box. I am not clear what > the #triggerForm method is for - it may have the effect of not > allowing the callback in the onChange to execute. > The javascript meaning of callbacks is way overloaded in the use > for seaside. > > Thanks for your help > > > _______________________________________________ > seaside mailing list > [hidden email] > http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside _______________________________________________ seaside mailing list [hidden email] http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside |
Robert Sirois <watchlala <at> hotmail.com> writes:
> > > It looks > > First of all, > Also, callbacks are > Thanks kindly for your answer and recommendations - I have cleaned up the code (paste http://paste.ubuntu.com/1172179/). It remains a mystery of why the callback for the #onChange event does not execute; I have placed a 'self halt' in the callback and also output to the Transcript. As use the same the #renderTheListWith: on : method in the callback, and the initial rendering. It could be possible, but I have not tried it to trigger the #onChange programmatically when the page is loaded and render the list via the callback. Eventually I would like to achieve the following scenario: 1. tabs represent the data for one type of loan. 2. A listbox A displayes a list of values dependent on the type of loan. 3. An input text computes via AJAX a price displayed in the input text box when the initial selection in listbox A is rendered, and when a selection is made in listbox A. I like to make the input text box display like a slider with a price at its middle, the range dependent on the type of loan and the selection in listbox A. 4. A multiselect listbox B displays values obtained via AJAX according to the type of loan, the selection in listbox A. The values selected by default depend on the loan type, the value selected in listbox A, and the slider in the input text box. _______________________________________________ seaside mailing list [hidden email] http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside |
Here's my advice... create a simple test application and just mess around with the scriptaculous stuff, keeping in mind that Seaside is not scriptaculous - it's just a wrapper.
The functions you are using are all in the original JavaScript library ( http://script.aculo.us/ ), but with Seaside you are able to utilize them in Smalltalk instead of straight JavaScript. All the callbacks and everything make the server-client interaction really clean. It's a great way to output web pages and have a super powerful backend behind them. Any JavaScript library you use will be exactly the same way. Look at the source and then figure out how to make it work in Seaside. Pharo and other Smalltalk IDEs make it easy to browse classes, and there's a lot of scriptaculous examples already built ( http://demo.seaside.st/javascript/scriptaculous ). After you get a test case built ( say, populating a select field from a text input ), then you'll find it a lot easier to add the next step ( ajax update to the server, then coming back to the client and populating the select field ). RS > To: [hidden email] > From: [hidden email] > Date: Tue, 28 Aug 2012 17:04:51 +0000 > Subject: [Seaside] Re: Help with JQuery example > > Robert Sirois <watchlala <at> hotmail.com> writes: > > > > > > > It looks > > > First of all, > > Also, callbacks are > > > Thanks kindly for your answer and recommendations - I have cleaned > up the code (paste http://paste.ubuntu.com/1172179/). It remains a mystery > of why the callback for the #onChange event does not execute; I have > placed a 'self halt' in the callback and also output to the Transcript. > > As use the same the #renderTheListWith: on : method in the > callback, and the initial rendering. It could be possible, but I have > not tried it to trigger the #onChange programmatically when the page > is loaded and render the list via the callback. > > Eventually I would like to achieve the following scenario: > 1. tabs represent the data for one type of loan. > 2. A listbox A displayes a list of values dependent on the type of loan. > 3. An input text computes via AJAX a price displayed in the input > text box when the initial selection in listbox A is rendered, and when > a selection is made in listbox A. I like to make the input text box > display like a slider with a price at its middle, the range dependent > on the type of loan and the selection in listbox A. > 4. A multiselect listbox B displays values obtained via AJAX according > to the type of loan, the selection in listbox A. The values selected > by default depend on the loan type, the value selected in listbox A, > and the slider in the input text box. > > > _______________________________________________ > seaside mailing list > [hidden email] > http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside _______________________________________________ seaside mailing list [hidden email] http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside |
In reply to this post by mozillanerd
I added this class method and executed it and
what did not run now ran.
initializePT " MyFirstComponent initializePT " (WAAdmin register: MyFirstComponent asApplicationAt: #mfc) addLibrary: PTDevelopmentLibrary; addLibrary: SUDevelopmentLibrary; exceptionHandler: WADebugErrorHandler; preferenceAt: #rootDecorationClasses put: #(); yourself. without this, the scriptaculous updater has nobody to talk to. Cheers, Bob On 8/28/12 1:04 PM, intrader wrote:
Robert Sirois <watchlala <at> hotmail.com> writes:It looks > First of all, Also, callbacks areThanks kindly for your answer and recommendations - I have cleaned up the code (paste http://paste.ubuntu.com/1172179/). It remains a mystery of why the callback for the #onChange event does not execute; I have placed a 'self halt' in the callback and also output to the Transcript. As use the same the #renderTheListWith: on : method in the callback, and the initial rendering. It could be possible, but I have not tried it to trigger the #onChange programmatically when the page is loaded and render the list via the callback. Eventually I would like to achieve the following scenario: 1. tabs represent the data for one type of loan. 2. A listbox A displayes a list of values dependent on the type of loan. 3. An input text computes via AJAX a price displayed in the input text box when the initial selection in listbox A is rendered, and when a selection is made in listbox A. I like to make the input text box display like a slider with a price at its middle, the range dependent on the type of loan and the selection in listbox A. 4. A multiselect listbox B displays values obtained via AJAX according to the type of loan, the selection in listbox A. The values selected by default depend on the loan type, the value selected in listbox A, and the slider in the input text box. _______________________________________________ seaside mailing list [hidden email] http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside _______________________________________________ seaside mailing list [hidden email] http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside |
In reply to this post by mozillanerd
intrader <intrader <at> aol.com> writes:
> > Robert Sirois <watchlala <at> hotmail.com> writes: > > > > > > > It looks > > > First of all, > > Also, callbacks are > > > Thanks kindly to both of you for your answer and recommendations. Onve I got the order: PTDevelopmentLibrary SUDevelopmentLibrary SUAllTestLibray You have done it in the class initialize. Once I get the mroe complex real world application running it will be a sight to see. I did this one some 6 years ago pre AJAX using iframes and XML/XSLT _______________________________________________ seaside mailing list [hidden email] http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside |
In reply to this post by squeakman
squeakman <squeakman <at> gmail.com> writes:
> > On 23/08/2012 6:53 PM, Bob Arning wrote: > > Well, now that you have the triggerSubmit in there, this seems to work: > Yes, that does call the "non-ajax callback" but now the callback marked > > "<=== this is never called" > > above is not called. > > Also, it seems that with the beSubmit added, the two lines marked > > "<=== not needed" > > are not needed. > incorrect statement about 'two @onClick' not allowed. I have resolver my issues with the great help from Arning and Sirois. This is the state of your last post: http://paste.ubuntu.com/1173021/ - do you still get the same result? and if so are you willing to include your while text and the library configuration? Thanks _______________________________________________ seaside mailing list [hidden email] http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside |
Free forum by Nabble | Edit this page |