Donald Ball <[EMAIL PROTECTED]> writes:

> That would work, but the formatting for the polls and their results need 
> to be easily customizable. That's far, far easier to do if I'm using kid 
> templates than if I'm constructing the HTML tree client-side. My page 
> designers can handle editing kid, asking them to edit javascript functions 
> isn't realistic.
>
> (Also, stylistically, I mislike requiring a javascript interpreter to 
> render the page. I like my webapps to still function in the absence of 
> one. But that's just me being pedantic.)

What I do here is using Kid's "fragment" option and then using innerHTML on
the JavaScript side. 

Something like:

    @turbogears.expose(fragment = True, html = 
'marketwatch.templates.some_example')
    def fragment_returning_method(self, *args, **kwargs):
        return dict(form = my_form)

And in your template:

<div py:strip="True" xmlns="http://www.w3.org/1999/xhtml"; 
     xmlns:py="http://purl.org/kid/ns#";>
  <form>
    <span py:replace="my_form.display(value = data)" />
    <input id='btn_save' onclick="save_form(this.form)" type="button" 
value="Save" />
  </form>
  <div id="next_form"></div>
</div>


My JavaScript looks like:

function save_form(form) {
    // Get all data...
    var d = postJSON('/my_page/save/', {...}; // Data from the form
    d.addCallback(new_form, form);
}


function new_form(form, data) {
    var new_form = get_html_form('/my_page/fragment_returning_method/');
    new_form.addCallback(add_form);
}

function add_form(data) {
    var pdata = data.responseText;
    var local = $('next_form');
    local.innerHTML = pdata;
}



I hope it is a good starting point.  Of course, the code above can be improved
since it was just a proof of concept for an application that I planned
developing. 


Be seeing you,
-- 
Jorge Godoy      <[EMAIL PROTECTED]>

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"TurboGears" 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/turbogears
-~----------~----~----~----~------~----~------~--~---

Reply via email to