TJ,
This worked great and expanded what I understand about prototype.
Thanks for posting it.
Thanks -BN
On May 28, 6:49 am, "T.J. Crowder" wrote:
> Hi,
>
> The usual thing would be to have a function that accepts the number
> and does the work, and have both the event handler and the onSuccess
> handler call it.
>
> function doTheEditThing(num)
> {
> // ...implementation...
>
> }
>
> ...
>
> onSuccess: function(response) {
> // ...do some checks on the response, and if valid:
> doTheEditThing(response.responseText);
>
> }
>
> ...
>
> Event.observe(therow, 'click', function(event) {
> doTheEditThing(this.id);
>
> });
>
> FWIW,
> --
> T.J. Crowder
> tj / crowder software / com
> Independent Software Engineer, consulting services available
>
> On May 27, 11:28 pm, BrentNicholas wrote:
>
>
>
> > Hi all,
>
> > So I'm wondering what is best practice.
>
> > I've got a table that users can click a row and get sent to an edit
> > screen.
>
> > I'm also sending the users to the same edit screen after data inserts.
>
> > I'd like to use the same function to handle this. However, when you
> > click the row it returns an event (from being observed). When you
> > insert the data, the function that does this calls ajax.request and
> > returns 'transport'. They both contain a number, though in different
> > formats.
>
> > So, what is best practice to handle this? The code below works fine if
> > broken into two unique functions, one that handles transport and
> > another that handles event. Seems really redundant to have two so
> > similar.
>
> > The following is a non-functional 'ideal':
>
> > function editProfessionalOutreach(event,transport) {
>
> > var key_ts_prof_outreach_seq;
>
> > // from row click
>
> > try {
> > var key_ts_prof_outreach_seq = this.id;
> > } catch (err) {
> > // none
> > }
>
> > // from insert function
>
> > try {
> > var key_ts_prof_outreach_seq = transport.responseText;
> > } catch (err) {
> > // none
> > }
>
> > alert('last:'+key_ts_prof_outreach_seq);
>
> > new Ajax.Request('dsp_editProfessionalOutreach.cfm?
> > KEY_TS_PROF_OUTREACH_SEQ='+key_ts_prof_outreach_seq+'&'+cfSession,
> > {
> > method: 'get',
> > onSuccess: outputProfessionalOutreach,
> > onComplete: attachProfessionalOutreachEditListeners,
> > onFailure: function(r) {
> > throw new Error( r.statusText );
> > }
> > }
> > );
>
> > }- Hide quoted text -
>
> - Show quoted text -
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups
"Prototype & script.aculo.us" group.
To post to this group, send email to prototype-scriptaculous@googlegroups.com
To unsubscribe from this group, send email to
prototype-scriptaculous+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/prototype-scriptaculous?hl=en
-~--~~~~--~~--~--~---