On Tuesday 03 April 2007 20:13, Jose Galvez wrote: > I'm not sure where your redundancy is: in your first controller you > build a page using index.mako, which I'm assuming has a div tag in it > that you will replace the contents of using ajax. Clicking the link > will replace the tagged content with the form defined in > ajax_edit.mako. Processing the form using saveform does stuff with the > data and then replaces the same div tag again with what gets rendered > from ajax_save.mako.
Correct. And ajax_save.mako prints the same string I already needed to print in index.mako because the page needs to look like before - just with the altered text. > If I understand you correctly you are only > updating a portion of the screen with each operation and only building > the entire page once with the index method. Could you please explain > the issue a little better? Sure. It would be easier to explain it over a pizza but since most of you are a few kilometers away I'll try here... :) def index() renders: ======================================== <h1>Curriculum vitae</h1> <div id="content"> I was born. Then I married. And now I'm programming Python. [FANCY AJAX EDIT LINK] </div> ======================================== When the user clicks on the edit link the <div> is replaced (call to editform()): ======================================== <form ...> <textarea name="cv"> I was born. Then I married. And now I'm programming Python. </textarea> </form> [FANCY AJAX SAVE LINK] ======================================== The user can edit the text and then submit it again which again replaces the <div> by (call to saveform()): ======================================== I was born. Then I married. And now I'm programming Python. [FANCY AJAX EDIT LINK] ======================================== So the redundancy is exactly the last block above. It would make sense to somehow include the last block in the template called/rendered by index(). I am rendering this block twice - first in the index() and then in the saveform(). It's trivial in this example. But imagine that the output is a bit more complicated so that writing the template's logic twice would be unfortunate. One of the problems is that I need to pass the id of the entry (there can be several <div>s on the page) to the template so just including isn't enough. I considered using <%def> and <%namespace> but hoped for an easier way. Does this make it clearer? Christoph --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "pylons-discuss" 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/pylons-discuss?hl=en -~----------~----~----~----~------~----~------~--~---
