In the InPlaceEditor, demoajaxreturn.html is just a regular html file, 
nothing special about it. The InPlaceEditor expects the server to return 
the updated contents, so in most cases if the user types something and 
hits ok, the class is changed to ".inplaceeditor-saving", the 
Ajax.Request sends the new name to the server, the server does something 
and returns (by simply printing/echoing) whatever value is appropriate. 
The server's response triggers the onComplete for the Ajax.Request which 
changes the CSS class back to ".inplaceeditor" or whatever it is.

However, in your case I'm not so sure you need IPE. Here is a simple 
example that doesn't use IPE:

<div id="indicator" style="display: none;"><img src="indicator.gif" 
alt="" /></div>
<form id="mailer_form">
    <input type="text" name="subject" />
    <textarea name="body"></textarea>
    <input type="submit" value="Submit" />
</form>
<script type="text/javascript">
    Event.observe('mailer_form','submit',function(event){
       Event.stop(event); //prevents the form from being submitted as a 
normal HTML form which would cause a page reload
       if( !/* is form valid? */){ return; }
       $('indicator').show(); //make your indicator visible
       new Ajax.Request('yourmailerhandlingpage.php',{
          parameters: Form.serialize(this), //"this" is the form's DOM 
element
          onComplete: function(){
             $('indicator').hide();
          }
        });
    });
</script>

In 'yourmailhandlingpage.php', $_POST == Array(subject => '', body => '')

Your PHP page doesn't have to do anything special, just use the POST 
values given to process the mass mailing and when it is done, exit 
normally. You could return info like the number of emails sent or 
whatnot rather easily (I'd suggest using JSON encoding) and then use the 
onComplete function to present that data to the user.

A progress bar would be more complicated, maybe someone else can help 
you out with that but I assume you would have to update the progress 
value via a file, session variable, database entry or something (that 
can be accessed from a separate php thread) inside the loop and then 
poll it periodically. Prototype has handy classes for this as well, just 
check out the documentation on prototypejs.org/api but since you're new 
to Ajax, see if you can swallow the above example before trying the 
progress bar.

Colin

[EMAIL PROTECTED] wrote:
> Hi all, this is my first post, so I'm wearing my flame-proof jacket.
>
> I am new to Ajax, and I am trying to devise a progress indicator for
> my application. Its written using the Codeigniter framework, ( should
> I mention that here? ), and the php just loops through an array of
> email addresses & names, sending a personalised email for each
> subscriber. Its a simple newsletter application for an even simpler
> CMS that I'm building.
>
> I want to display a progress indicator whilst the email is being sent.
> Ideally showing the precentage so far, but most likely due to my
> limited ajax know-how, it will be a simple animated gif.
>
> I'm looking at doing it using script.aculo.us, but I was hoping
> someone may be able to help, in any way possible, on my steep learning
> curve.
>
> I found this on the scriptaculous wiki, but I'm still trying to
> understand it.
>
> <style type="text/css" media="screen">
>   .inplaceeditor-saving { background: url(/images/wait.gif) bottom
> right no-repeat; }
> </style>
>
> <p id="editme3">Click me, click me!</p>
> <script type="text/javascript">
>  new Ajax.InPlaceEditor('editme3', '/demoajaxreturn.html');
> </script>
>
> What does the demoajaxreturn.html actually do?
>
> Thanks
>
>
> >
>
>   


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Spinoffs" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-spinoffs?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to