Hi,

In the below example, I am trying to invoke javascript when I click on
Approve link and also on Disapprove. [While disapproving, I am submitting
the form as I want to submit reported category along with it, while on
approve I am just changing the status[approve/disapprove] of my photo in
java code ]
Photos.tml
<t:loop source="photoDetails" value="each" index="counter">  
   <div t:type="zone" t:id="photoZone" id="prop:zoneId">
        <t:form t:id="formId" t:zone="prop:zoneId">
       <t:hidden value="counter"/>
 [<t:actionlink t:id="approvePhotos" context="${counter}" zone="prop:zoneId"
t:mixins="Confirm">Approve</t:actionlink>]
 <p><t:label for="reportedCategory"/>
         <t:select t:id="reportedCategory" t:label="Category"/></p>
 <input type="submit" t:type="submit" t:id="photo" value="Disapprove Photo"
onClick="extraStep(${counter});" />
 </t:form>
   </div>        
 </t:loop>   

Everything works fine, except that my javascript code is invoked when I move
from Index page to Photos page and not on clicking 'approve link'. The logic
which I have used for Disapprove doesn't work with 'approve' actionLink.

my Confirm.java is as follows:
@IncludeJavaScriptLibrary("Confirm.js")
public class Confirm {

    @Parameter(value = "Are you sure?", defaultPrefix =
BindingConstants.LITERAL)
    private String message;

    @Inject
    private RenderSupport renderSupport;

    @InjectContainer
    private ClientElement element;

    @AfterRender
    public void afterRender() {
            renderSupport.addScript(String.format("new Confirm('%s');",
                          element.getClientId()));
    }
   
}

Confirm.js
var Confirm = Class.create();
Confirm.prototype = {
        initialize: function(element) {
                alert("element" + element);
                Event.observe($(element), 'click',
this.doConfirm.bindAsEventListener(this));
        },
        
        doConfirm: function(e) {        
        e.style.display = 'none';
        alert("in javascript in js file");
        e.stop();
        }
}

Kindly help me as to how can I invoke javascript on clicking approve link.

Looking forward for your support.

Regards
Sakshi
-- 
View this message in context: 
http://old.nabble.com/Invoke-javascript-through-Mixin-with-actionLink-and-click-event-tp29052536p29052536.html
Sent from the Tapestry - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
For additional commands, e-mail: users-h...@tapestry.apache.org

Reply via email to