hi @ all how can i save my edited text in the database with php? thanks for your support --~--~---------~--~----~------------~-------~--~----~ 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 rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---
You catch a form submission, process it, and return success or failure. In the parameters of the IPE, you specify where the form is to submit to. You can also define (through a callback) the name of the variable that is posted to your form handler (default is ''value''). If you simply do this: new Ajax.InPlaceEditor("listing_body", "ajax_update.php?id=$id", {rows:20,cols:50}); You would catch it like this (inside ajax_update.php): header(''Content-Type: text/html; charset=utf-8''); include_once(''config.inc.php''); $id = $_GET[''id''] + 0; $value = $_POST[''value'']; if($page = ActiveRecord::FindById(''listings'',$id)){ $page->description = $value; if($page->save()){ echo $page->m($field); }else{ echo "<h3>ERROR SAVING UPDATE</h3><p>Reload page to restore original values.</p>"; } } Does this help? Walter On Mar 15, 2007, at 12:53 PM, Zafer wrote:> > hi @ all > > how can i save my edited text in the database with php? > > thanks for your support > > > >--~--~---------~--~----~------------~-------~--~----~ 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 rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---
when i use a TEXTAREA with in-place-editor, all sorts of weird stuff happens - like it disappears, or the callbacks don''t work, the ''wait'' indicator stops working after the first save, i never get a ''Save...'' message, etc. is this all from using a TEXTAREA as opposed to a P tag? also, is there a non-hack way to not pre-select all the text in the textarea? On Mar 15, 3:44 pm, Walter Lee Davis <w...-HQgmohHLjDZWk0Htik3J/w@public.gmane.org> wrote:> You catch a form submission, process it, and return success or failure. > > In the parameters of the IPE, you specify where the form is to submit > to. You can also define (through a callback) the name of the variable > that is posted to your form handler (default is ''value''). > > If you simply do this: > > new Ajax.InPlaceEditor("listing_body", "ajax_update.php?id=$id", > {rows:20,cols:50}); > > You would catch it like this (inside ajax_update.php): > > header(''Content-Type: text/html; charset=utf-8''); > include_once(''config.inc.php''); > $id = $_GET[''id''] + 0; > $value = $_POST[''value'']; > if($page = ActiveRecord::FindById(''listings'',$id)){ > $page->description = $value; > if($page->save()){ > echo $page->m($field); > }else{ > echo "<h3>ERROR SAVING UPDATE</h3><p>Reload page to restore original > values.</p>"; > } > > } > > Does this help? > > Walter > > On Mar 15, 2007, at 12:53 PM, Zafer wrote: > > > > > hi @ all > > > how can i save my edited text in the database with php? > > > thanks for your support--~--~---------~--~----~------------~-------~--~----~ 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 rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---
On Mar 16, 2007, at 11:14 AM, Peter2 wrote:> > when i use a TEXTAREA with in-place-editor, all sorts of weird stuff > happens - like it disappears, or the callbacks don''t work, the ''wait'' > indicator stops working after the first save, i never get a ''Save...'' > message, etc. is this all from using a TEXTAREA as opposed to a P tag? >Not sure what you mean here. Do you mean if you set the editor to use columns and rows, rather than letting it default to a single-line (input type=text) you get different behavior? I haven''t seen that personally, and I have used both types of IPE.> also, is there a non-hack way to not pre-select all the text in the > textarea? >There was a long discussion of this recently on this list. Please have a search of the archives. Walter --~--~---------~--~----~------------~-------~--~----~ 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 rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---
yes, that''s part of what i mean, but the more important part is that i want to _start with_ a textarea. that is, i want a TEXTAREA on my screen - not a one-line INPUT element. here is my code: <textarea id="editme" rows="5" cols="50">This is what is in the box already.</textarea> <script type="text/javascript"> new Ajax.InPlaceEditor(''editme'', ''/ajaxWaitReturn.php'', {rows:5,cols:50}); </script> The ''ajaxWaitReturn.php'' script just sleeps 5 seconds, then ends. So, taking easy things first, there never is a ''Saving...'' message - whether I use a ''wait/spinning'' icon or not. Is this normal? A bug? (didn''t realize this forum was the same as the google group sort of.) On Mar 16, 9:39 am, Walter Lee Davis <w...-HQgmohHLjDZWk0Htik3J/w@public.gmane.org> wrote:> On Mar 16, 2007, at 11:14 AM, Peter2 wrote: > > > > > when i use a TEXTAREA with in-place-editor, all sorts of weird stuff > > happens - like it disappears, or the callbacks don''t work, the ''wait'' > > indicator stops working after the first save, i never get a ''Save...'' > > message, etc. is this all from using a TEXTAREA as opposed to a P tag? > > Not sure what you mean here. Do you mean if you set the editor to use > columns and rows, rather than letting it default to a single-line > (input type=text) you get different behavior? I haven''t seen that > personally, and I have used both types of IPE. > > > also, is there a non-hack way to not pre-select all the text in the > > textarea? > > There was a long discussion of this recently on this list. Please have > a search of the archives. > > Walter--~--~---------~--~----~------------~-------~--~----~ 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 rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---
i solved part of the Textarea problem - that of changing/disappearing text. You have to explicitly update the ''value'' and ''defaultValue'' properties of the textarea to prevent the InPlaceEditor control from clearing it out. it would seem sensible to me, then, to wait for an ''ok on save'' from your server, and then just set these two variables locally on the form. i''ll try that. not sure how to deal with ''not authorized'' or ''not logged-in'' type of error messages yet. is that part of one of these frameworks? like, do I need a parallel server-side infrastructure to handle just AJAX requests? and then, do i need to start sending 403s or whatever the ''not auth'' responses are, as opposed to just sending a ''200 ok'', and then sending back some structured - one, a flag for success or failure, two, a possible error message, three some actual data? what else? On Mar 16, 12:49 pm, "Peter2" <psmit...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> yes, that''s part of what i mean, but the more important part is that > i > want to _start with_ a textarea. that is, i want a TEXTAREA on my > screen > - not a one-line INPUT element. here is my code: > > <textarea id="editme" rows="5" cols="50">This is what is in the box > already.</textarea> > > <script type="text/javascript"> > new Ajax.InPlaceEditor(''editme'', ''/ajaxWaitReturn.php'', > {rows:5,cols:50}); > </script> > > The ''ajaxWaitReturn.php'' script just sleeps 5 seconds, then ends. So, > taking easy things first, there never is a ''Saving...'' message - > whether > I use a ''wait/spinning'' icon or not. Is this normal? A bug? > > (didn''t realize this forum was the same as the google group sort of.) > > On Mar 16, 9:39 am, Walter Lee Davis <w...-HQgmohHLjDZWk0Htik3J/w@public.gmane.org> wrote: > > > On Mar 16, 2007, at 11:14 AM, Peter2 wrote: > > > > when i use a TEXTAREA with in-place-editor, all sorts of weird stuff > > > happens - like it disappears, or the callbacks don''t work, the ''wait'' > > > indicator stops working after the first save, i never get a ''Save...'' > > > message, etc. is this all from using a TEXTAREA as opposed to a P tag? > > > Not sure what you mean here. Do you mean if you set the editor to use > > columns and rows, rather than letting it default to a single-line > > (input type=text) you get different behavior? I haven''t seen that > > personally, and I have used both types of IPE. > > > > also, is there a non-hack way to not pre-select all the text in the > > > textarea? > > > There was a long discussion of this recently on this list. Please have > > a search of the archives. > > > Walter--~--~---------~--~----~------------~-------~--~----~ 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 rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---
On Mar 16, 2007, at 3:49 PM, Peter2 wrote:> > yes, that''s part of what i mean, but the more important part is that > i > want to _start with_ a textarea. that is, i want a TEXTAREA on my > screen > - not a one-line INPUT element. here is my code: > > <textarea id="editme" rows="5" cols="50">This is what is in the box > already.</textarea> > > <script type="text/javascript"> > new Ajax.InPlaceEditor(''editme'', ''/ajaxWaitReturn.php'', > {rows:5,cols:50}); > </script> > > The ''ajaxWaitReturn.php'' script just sleeps 5 seconds, then ends. So, > taking easy things first, there never is a ''Saving...'' message - > whether > I use a ''wait/spinning'' icon or not. Is this normal? A bug? > > (didn''t realize this forum was the same as the google group sort of.) > > > On Mar 16, 9:39 am, Walter Lee Davis <w...-HQgmohHLjDZWk0Htik3J/w@public.gmane.org> wrote: >> On Mar 16, 2007, at 11:14 AM, Peter2 wrote: >> >> >> >>> when i use a TEXTAREA with in-place-editor, all sorts of weird stuff >>> happens - like it disappears, or the callbacks don''t work, the ''wait'' >>> indicator stops working after the first save, i never get a ''Save...'' >>> message, etc. is this all from using a TEXTAREA as opposed to a P >>> tag? >> >> Not sure what you mean here. Do you mean if you set the editor to use >> columns and rows, rather than letting it default to a single-line >> (input type=text) you get different behavior? I haven''t seen that >> personally, and I have used both types of IPE. >> >>> also, is there a non-hack way to not pre-select all the text in the >>> textarea? >> >> There was a long discussion of this recently on this list. Please have >> a search of the archives. >> >> Walter > >That''s whacked! It''s a textarea, so just use that! Are you trying to get the textarea''s form to submit over Ajax? Cuz that''s pretty easy: (in your <form> tag) onsubmit="Element.show(''spinner''); new Ajax.Updater(''parent_div_of_the_form'', ''form_handler.php'', {asynchronous:true, parameters:Form.serialize(this)}); return false;" I''m not at all clear why you would have a form element and then make the form element itself editable with IPE. Form elements are editable to begin with! Walter --~--~---------~--~----~------------~-------~--~----~ 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 rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---
isn''t that the whole point of IPE, to make elements, you know, Editable In Place? if everyone wanted to use FORMs then we would never have any reason for an IPE, but someone decided that this IPE thing might be a good idea, that there was value in it, and i happen to agree. my issue is with the extremely limited nature of the element. to use it, i pretty much have to rewrite it from the ground up. that''s fine, but it''s presented as something that''s essentially ready to use, and then i find out that there''s no built-in/configurable way to unselect all the text upon entering edit mode. stuff like that is frustrating as all get out. there''s no reason i can see that this element can''t do everything we want it to. there''s no reason not to have a simple working example on the website of something not completely trivial. there''s no reason to not explain design decisions at an api level. i mean, you have to plop the same event code into your HTML for ever single instance of the IPE you want to use - one for each unique element ID. how about a simple selector mechanism based on class or element type or _anything_? no configurable translation for nl2br(). and, more on the TEXTAREA, maybe i want my screen to look essentially the same when a user ''activates'' an element for edit mode - i don''t want my page shifting all over the place based on some arbitrary number of columns and rows. this seems possible with a simple input box, but what if i wanted something useful, like a TEXTAREA? so, what needs to happen is I need to update the documentation on the scriptaculous page so that it doesn''t give the false impression that this IPE element can be used in anything other than the most limited circumstances - unless you''re ready to rewrite it yourself. i need to update the docs so that they make more clear that your server-side script must return the text you just sent to the server-side script. then i need to look at this IPE code and make it work for TEXTAREAs. then i need to add a config option to not select/highlight the existing text. scripcrapulous. that''s what i say. i tried jquery, too, and that thing didn''t even _think_ about being useful. On Mar 19, 8:01 am, Walter Lee Davis <w...-HQgmohHLjDZWk0Htik3J/w@public.gmane.org> wrote:> On Mar 16, 2007, at 3:49 PM, Peter2 wrote: > > > > > > > yes, that''s part of what i mean, but the more important part is that > > i > > want to _start with_ a textarea. that is, i want a TEXTAREA on my > > screen > > - not a one-line INPUT element. here is my code: > > > <textarea id="editme" rows="5" cols="50">This is what is in the box > > already.</textarea> > > > <script type="text/javascript"> > > new Ajax.InPlaceEditor(''editme'', ''/ajaxWaitReturn.php'', > > {rows:5,cols:50}); > > </script> > > > The ''ajaxWaitReturn.php'' script just sleeps 5 seconds, then ends. So, > > taking easy things first, there never is a ''Saving...'' message - > > whether > > I use a ''wait/spinning'' icon or not. Is this normal? A bug? > > > (didn''t realize this forum was the same as the google group sort of.) > > > On Mar 16, 9:39 am, Walter Lee Davis <w...-HQgmohHLjDZWk0Htik3J/w@public.gmane.org> wrote: > >> On Mar 16, 2007, at 11:14 AM, Peter2 wrote: > > >>> when i use a TEXTAREA within-place-editor, all sorts of weird stuff > >>> happens - like it disappears, or the callbacks don''t work, the ''wait'' > >>> indicator stops working after the first save, i never get a ''Save...'' > >>> message, etc. is this all from using a TEXTAREA as opposed to a P > >>> tag? > > >> Not sure what you mean here. Do you mean if you set the editor to use > >> columns and rows, rather than letting it default to a single-line > >> (input type=text) you get different behavior? I haven''t seen that > >> personally, and I have used both types of IPE. > > >>> also, is there a non-hack way to not pre-select all the text in the > >>> textarea? > > >> There was a long discussion of this recently on this list. Please have > >> a search of the archives. > > >> Walter > > That''s whacked! It''s a textarea, so just use that! Are you trying to > get the textarea''s form to submit over Ajax? Cuz that''s pretty easy: > > (in your <form> tag) > onsubmit="Element.show(''spinner''); new > Ajax.Updater(''parent_div_of_the_form'', ''form_handler.php'', > {asynchronous:true, parameters:Form.serialize(this)}); return false;" > > I''m not at all clear why you would have a form element and then make > the form element itself editable with IPE. Form elements are editable > to begin with! > > Walter--~--~---------~--~----~------------~-------~--~----~ 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 rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---
On Mar 19, 2007, at 2:15 PM, Peter2 wrote:> isn''t that the whole point of IPE, to make elements, you know, > Editable In Place? > > if everyone wanted to use FORMs then we would never have any reason > for an IPE, but someone decided that this IPE thing might be a good > idea, that there was value in it, and i happen to agree.Yes, but who ever needed to edit an editable thing? That reminds me of the picture of the wine bottle with the picture of the wine bottle on the label with the picture... It sounds to me as though you are frustrated with the bare-bones IPE. Which is fine, and understandable. But the way that you are going about fixing it -- you could simply make a custom form page and use other parts of scriptactulous to make that form submit out-of-band, i.e.: in the same way that the IPE works. Then you could also set the default behavior of your Textarea to not be selected. You could make the page not jump around, etc. IPE is a very general purpose tool, and to get it to fit into your scheme may be more work than it''s worth. Really, you are rowing upstream as fast as you can here, but this seems to me to be a lot of effort to fix something which I''m not convinced is broken. I use IPE in places. I also use Ajax.Updater to handle form submits, as I demo''d to you. They each have their place. Finally, take a careful look at the css rules that you can apply to the IPE. That may fix your entire issue with the page jumping around and changing shape on you. Fix the visual problem in the presentation layer -- the plumbing and structure work just fine. Walter --~--~---------~--~----~------------~-------~--~----~ 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 rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---