(This is a beginners'' question) I can''t seem to find this in the wiki or in the list archives. Button says "subscribe". User clicks. Button says "loading". Then button says "unsubscribe". (or the other way round) Apologies for the simplicity of the question, but any help is appreciated. Thanks, Peter
Peter, Shouldn''t be to hard. Simply catch the button onClick event and change it''s name to "loading". Then send the Ajax request. When the response arrives, you will have to call another function which will change the name to "unsubscribe". However, you should think about whether it is necessary to give such a feedback. Does the user really care whether something is happening in the background, and does he have to wait until this task is finished? I would simply change the value of the button without waiting for the request to come back. Of course you should let the user know if something went wrong... but to do this, a simple error message would be sufficient. Cheers, Jens On 21/10/2005, at 2:02 PM, Peter Van Dijck wrote:> (This is a beginners'' question) > > I can''t seem to find this in the wiki or in the list archives. Button > says "subscribe". User clicks. Button says "loading". Then button says > "unsubscribe". (or the other way round) > > Apologies for the simplicity of the question, but any help is > appreciated. > > Thanks, > Peter > _______________________________________________ > Rails-spinoffs mailing list > Rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs >
Thanks Jens! That''s good UI advice. I hadn''t thought of that. Peter> However, you should think about whether it is necessary to give such > a feedback. Does the user really care whether something is happening > in the background, and does he have to wait until this task is > finished? I would simply change the value of the button without > waiting for the request to come back. Of course you should let the > user know if something went wrong... but to do this, a simple error > message would be sufficient. > > Cheers, > Jens > > > On 21/10/2005, at 2:02 PM, Peter Van Dijck wrote: > > > (This is a beginners'' question) > > > > I can''t seem to find this in the wiki or in the list archives. Button > > says "subscribe". User clicks. Button says "loading". Then button says > > "unsubscribe". (or the other way round) > > > > Apologies for the simplicity of the question, but any help is > > appreciated. > > > > Thanks, > > Peter > > _______________________________________________ > > Rails-spinoffs mailing list > > Rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > > http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs > > > > _______________________________________________ > Rails-spinoffs mailing list > Rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs >
I was curious what the rest of you are doing to keep the size of using scriptaculous manageable. It seems for just using drag and drop with a few effects you''re looking at loading quite a lot of javascript. Does anyone know an automated way of seperating just the functions that will be used in the site from the rest? I wouldn''t want to have to do that every time scriptaculous is patched so I''m thinking there has to be a better way. Joe
You can use dojo''s compressor to help out. It works on most (if not all) javascript files since it actually embeds rhino (mozilla''s javascript engine) to determine what javascript is actually touchable from the file. This will drop out sections of the code that you aren''t using as well as compress the functions themselves (although it doesn''t rename them as it doesn''t want to break the API) http://alex.dojotoolkit.org/shrinksafe/ Jesse On 10/22/05, Joe Black <joeblackde-PkbjNfxxIARBDgjK7y7TUQ@public.gmane.org> wrote:> I was curious what the rest of you are doing to keep the size of using > scriptaculous manageable. It seems for just using drag and drop with a > few effects you''re looking at loading quite a lot of javascript. > > Does anyone know an automated way of seperating just the functions that > will be used in the site from the rest? I wouldn''t want to have to do > that every time scriptaculous is patched so I''m thinking there has to be > a better way. > > Joe > > > > _______________________________________________ > Rails-spinoffs mailing list > Rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs >
You can directly include the files instead of using the scriptaculous.js loader file. So instead of (with the latest version from SVN): <script src="some_dir/scriptaculous.js" type="text/javascript"></script> do <script src="some_dir/effects.js" type="text/javascript"></script> <script src="some_dir/dragdrop.js" type="text/javascript"></script> If you want effects and drag and drop functionality (of course, you always need to include prototype.js, too). There''s only one dependency, that is that effects.js is required to use all the other .js files, so it needs to be always included. The next version of script.aculo.us (that is, post 1.5) will include are more advanced mechanism to do this. btw, personally I would not rely on JavaScript compressors, because: 1) it gets really difficult to debug when something bad happens 2) they can introduce new bugs 3) compression should be done by the webserver (transparent g-zipping) Thomas Am 23.10.2005 um 05:29 schrieb Joe Black:> I was curious what the rest of you are doing to keep the size of using > scriptaculous manageable. It seems for just using drag and drop with a > few effects you''re looking at loading quite a lot of javascript. > > Does anyone know an automated way of seperating just the functions > that > will be used in the site from the rest? I wouldn''t want to have to do > that every time scriptaculous is patched so I''m thinking there has > to be > a better way. > > Joe > > > > _______________________________________________ > Rails-spinoffs mailing list > Rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs >