How to apply JQuery selector to Wicket ModalWindow
I'm using one of the spiffy new show-your-password-single-char JQuery hacks, which I can apply to my all password fields on a page with
<script type=开发者_StackOverflow社区"text/javascript">
$(document).ready( function() {
$('input:password').dPassword();
});
</script>
But my change password dialog is rendered in a Wicket ModalWindow,
final ModalWindow window = new ModalWindow("change-password-panel");
final PasswordChangePanel panel = new PasswordChangePanel(window, myPasswordValidator);
window.setContent(panel);
add(window);
add(new AjaxFallbackLink<String>("change-password") {
@Override public void onClick(AjaxRequestTarget target) {
window.show(target);
}});
so it isn't there on document.ready.
How can I arrange to re-run the JQuery selector when my ModalWindow has been shown?
Try sending back some JS to run upon completion of the AJAX call:
add(new AjaxFallbackLink<String>("change-password") {
@Override
public void onClick(AjaxRequestTarget target) {
target.appendJavascript("$('input:password').dPassword();")
window.show(target);
}
});
It's better to restrict the scope of the selector to just your modal window, but I'd need to see the code to be able to do that. ;)
精彩评论