You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by John <jo...@quivinco.com> on 2014/09/04 19:21:52 UTC
making small changes to js functionality without a whol enew component?
Hi,
I just wanted to make a small change to the function of jquery.dialog component. There's a couple lines of jquery to tidy up the DOM and help me avoid a whole pile of code to generate unique ids only to be wasting memory with the component being in the DOM multiple times when it's modal and a sort of singleton widget.
I'd like to extend the component is some way or attach somehow to the js without cloning the whole thing. Is there perhaps a way to override the existing js or better still have my additional js somehow rendered with the component without including in the template as below which seems messy?
What would be most framework friendly? I may also want the id of the node to remove be parameterised but not a problem right now because this added feature is just needed for this component. I'm thinking I could justy include this js in an outer component and make sure it is run only at the end of the page render but I quite like the idea of attaching the code to the component concernes as far as SOC goes?
John
<t:jquery.dialog t:clientId="bookingsDiaryDialog" id="bookingsDiaryDialog" params="${diaryDlgParams}" title="${message:title.diary}">
<t:zone t:id="bookingsDiaryZone" id="bookingsDiaryZone">
<t:if t:test="showDiary">
<t:diary workIdParm="workId" venueIdParm="venueId" reservationIdParm="reservationId" reservationUuidParm="reservationUuid"/>
</t:if>
<t:if t:test="showCourtesy">
<t:bookingadvice vendorIdParm="${reservationVendorId}" bookingCompleteParm="${bookingComplete}"/>
</t:if>
<t:if t:test="dirtyDiary">
<p>${message:text.diarydirty}</p>
</t:if>
</t:zone>
<script>
$('#bookingsDiaryDialog').bind('dialogclose', function(event) {
$('#diary').remove();
});
</script>
</t:jquery.dialog>
---
This email is free from viruses and malware because avast! Antivirus protection is active.
http://www.avast.com
Re: making small changes to js functionality without a whol enew
component?
Posted by Thiago H de Paula Figueiredo <th...@gmail.com>.
On Thu, 04 Sep 2014 14:21:52 -0300, John <jo...@quivinco.com> wrote:
> Hi,
Hi!
> I'd like to extend the component is some way or attach somehow to the js
> without cloning the whole thing.
Depending on how the original code is written, you can monkey-patch it. If
not, you can try setting up a LinkRewriter so the requests for the
original JS end up returning your JS file instead.
> <t:jquery.dialog t:clientId="bookingsDiaryDialog"
> id="bookingsDiaryDialog" params="${diaryDlgParams}"
> title="${message:title.diary}">
Never, never, never ever use ${} when passing parameters to Tapestry
component or mixin parameters. When it's not completely wrong and a bug,
it's useless. I've written this so many times in the mailing list I won't
repeat why it's either wrong or useless. It should have been
params="prop:diaryDlgParams" title="message:title.diary">
--
Thiago H. de Paula Figueiredo
Tapestry, Java and Hibernate consultant and developer
http://machina.com.br
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org
Re: making small changes to js functionality without a whol enew component?
Posted by Lance Java <la...@googlemail.com>.
The web classloader will look in WEB-INF/classes before attempting to
locate resources in a jar file.
So if you put the override file in src/main/resources of your war project
it should take precedence.