[gatein-issues] [JBoss JIRA] (GTNPORTAL-2875) JQuery bound events don't work after "save" in the "edit navigation"
Vu Viet Phuong (JIRA)
jira-events at lists.jboss.org
Mon May 20 23:15:06 EDT 2013
[ https://issues.jboss.org/browse/GTNPORTAL-2875?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12775490#comment-12775490 ]
Vu Viet Phuong commented on GTNPORTAL-2875:
-------------------------------------------
{code}
(function($){
$("#testbutton").click(function(){
alert("Nice click!")
});
})(jQuery);
{code}
this js will be served as GMD js module, notice that a module will not be served (and run) 2 times, in ajax request, the html page is not re-rendered
You can use this js instead:
{code}
(function($){
$(document).on('click.testbutton', "#testbutton").click(function(){
alert("Nice click!");
});
})(jQuery);
{code}
Sometime, we may need to run some js after an ajax response. We should add that js snipet as a callback to require statement like this:
{code}
//code in groovy template
def jsMan = WebuiRequestContext.getCurrentInstance().getJavascriptManager();
jsMan.require("SHARED/module").addScript("....."); //add your js as callback to require statement
{code}
> JQuery bound events don't work after "save" in the "edit navigation"
> --------------------------------------------------------------------
>
> Key: GTNPORTAL-2875
> URL: https://issues.jboss.org/browse/GTNPORTAL-2875
> Project: GateIn Portal
> Issue Type: Bug
> Security Level: Public(Everyone can see)
> Affects Versions: 3.5.0.Final
> Reporter: Viliam Rockai
> Attachments: test-portlet.zip
>
>
> If you add a portlet using JQuery to layout, so it's visible while using the administration interface of "Site", you would be able to reproduce the issue.
> I'm attaching the portlet as an attachment (src + war in the target directory). Put it somewhere on the page and go to the "Site" management. If you click on the portlet link, an alert will pop-up. When you click on the "edit navigation" -> "save" (save even without doing any changes), the link won't respond to clicking any more.
> After the save button is pressed, the page is reloaded by ajax, but it seems that it doesn't handle the JS correctly.
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira
More information about the gatein-issues
mailing list