Two cases... one works, one does not, and the difference seems to be
that in Case 2 (non-working) the form is displayed in the view only
after the user clicks a button that triggers an
update_element_function to show the form.  So there seems to be
something I'm not understanding -- maybe about filtering or escaping?
-- which is preventing the observer from working.  Too bad no error
messages in the non-working case, just silence where I expect an Ajax
call.  The following are in a Mako template with the standard pylons
helpers %included at the top.


<%def name="trial()" buffered="True">
${h.form_remote_tag(
    url=h.url_for(
        controller="FVal",
        action="add",
        feature_id=999,
        parentFVal_id=666),
    complete=h.evaluate_remote_response(),
    method="POST")}
test feature main:
${h.text_field(name="main value")}
${h.text_field(name="foo")}
% if True:
    ${h.observe_field(
        "foo",
        with_="{foo:value}",
        url=h.url_for(
            controller="FVal",
            action="alter_input_form"))}
% endif
${h.submit("save", name="commit")}
${h.end_form()}
</%def>

this version WORKS:
${trial()}

but this one DOES NOT WORK: (no Ajax call ever happens)
<div id="whatever">
${h.button_to_function(
    "Test",
    h.update_element_function(
        "whatever",
        action="update",
        content=(trial())))}
</div>


I'm looking at the results via Firebug.  As far as I can tell, both
versions generate the same HTML and same javascript.  The only
difference I can see is that in the 2nd case, the form is not put on
the page until the user clicks the "Test" button.

Why should the update_element_function somehow result in breaking the
Ajax of the observe_field function?  The form in each case is
identical:

<form onsubmit="new Ajax.Request('/FVal/add?
feature_id=999&parentFVal_id=666', {asynchronous:true,
evalScripts:true, method:'POST', onComplete:function(request)
{eval(request.responseText)}, parameters:Form.serialize(this)});
return false;" method="post" action="/FVal/add?
feature_id=999&parentFVal_id=666">
test feature main:
<input type="text" name="main value" id="main value"/>
<input type="text" name="foo" id="foo"/>
    <script type="text/javascript">
//<![CDATA[
new Form.Element.EventObserver('foo', function(element, value) {new
Ajax.Request('/FVal/alter_input_form', {asynchronous:true,
evalScripts:true, parameters:{foo:value}})})
//]]>
</script>
<input type="submit" value="save" name="commit"/>
</form>

And specifically, the Form.Element.EventObserver generated in both
cases is identical.

So there's gotta be something I'm missing!
Any insight would be most welcome, thanks.

Eric

--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to