You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Travis Romney <tr...@gmail.com> on 2010/11/01 23:34:22 UTC
Mixing zone updates and custom events.
>
> I'm having some issues mixing zones and my own custom ajax events.
>
What is happening is when I update a zone via the form submit.
My other event listeners get removed from the page.
> For example:
>
> I have a simple form that contains a zone like the following:
>
> <t:form t:id="form" zone="myZone">
> <t:zone id="myZone">
> <t:TextField t:id="name" value="name"/>
> <t:Submit t:id="add" value="Add">
> </t:zone>
>
</t:form>
>
outside the form I'll have some other input elements
<input t:type="any" id="outsideTheForm" value="prop:someValueFromThePage"/>
For this element I'll add a prototype event listener, like the following:
var MyClass = Class.create({
function: initialize(eventUrl) {
this.eventUrl = eventUrl;
$("outsideTheForm").observe("keyUp", this.doSomething.bind(this));
},
function: doSomething() {
new Ajax.Request(this.eventUrl, {
onSucess: function(transport) {
var json = transport.responseJSON;
alert(json.message);
}
});
}
});
The events for this element work perfectly fine, until I click the submit
button
within the ajax form. Once I click on the submit button my ajax events
cease to function.
I've found that I can re-initialize my events after a zone update, but this
is very tedious,
and sometimes I don't have the proper context information that I need
to re-initialize
my javascript events (This can be worked around as well. But it gets messy).
Is there a way to prevent zone updates from removing all of my event
listeners?
Or a more preferred method for something like this?
I would appreciate any feedback?
Regards,
Travis Romney
Re: Mixing zone updates and custom events.
Posted by Travis Romney <tr...@gmail.com>.
That worked perfectly, and cleaned up the code quite nicely.
Thanks for the tip.
Regards,
Travis Romney
On Tue, Nov 2, 2010 at 7:22 AM, LLTYK <LL...@mailinator.com> wrote:
>
> The main reason I see for events suddenly stopping is the element you
> observed being inside the zone, and being trashed on zone reload.
>
> I feel like you should actually be using a mixin on the textfield, since
> that's probably where you want the keyup events. A mixin will automatically
> reinitialize it's javascript again on zone reload, and also get a handle on
> the tapestry generated id instead of a hardcoded one as well.
> --
> View this message in context:
> http://tapestry-users.832.n2.nabble.com/Mixing-zone-updates-and-custom-events-tp5695382p5697155.html
> Sent from the Tapestry Users mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>
>
Re: Mixing zone updates and custom events.
Posted by LLTYK <LL...@mailinator.com>.
The main reason I see for events suddenly stopping is the element you
observed being inside the zone, and being trashed on zone reload.
I feel like you should actually be using a mixin on the textfield, since
that's probably where you want the keyup events. A mixin will automatically
reinitialize it's javascript again on zone reload, and also get a handle on
the tapestry generated id instead of a hardcoded one as well.
--
View this message in context: http://tapestry-users.832.n2.nabble.com/Mixing-zone-updates-and-custom-events-tp5695382p5697155.html
Sent from the Tapestry Users mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org