You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by liza6218 <l6...@hotmail.com> on 2008/09/03 20:40:22 UTC

Add a javascript window to a Link when text input not saved

Hi,

I'm trying to figure out the following, any help will be apreciated.

I have a form with 3 TextFields , a DropDownChoice and  a save button , 
and a BookmarkablePageLink in the page.  

I need to add a javascript confirm window to the Link whenever any input
changed without save (submit).
and remove the confirm window when the change is saved.


public aPage() {
        form = new Form("form");

	DropDownChoicequestion questions = new DropDownChoice("question", ...);
        form.add(questions);

	TextField answer1 = new RequiredTextField("answer1");
	TextField answer2 = new RequiredTextField("answer2");
	TextField answer3 = new RequiredTextField("answer3");

	form.add(answer1);
	form.add(answer2);
	form.add(answer3);

	form.add(new Button("save") {
            @Override
            public void onSubmit() {
	         saveChanges();
		 //remove the confirm window
	    }
	 }

        add(form);
	
	BookmarkablePageLink alink = new BookmarkablePageLink("alink",
LinkPage.class));
	add(alink);
}


-- 
View this message in context: http://www.nabble.com/Add-a-javascript-window-to-a-Link-when-text-input-not-saved-tp19295365p19295365.html
Sent from the Wicket - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: Add a javascript window to a Link when text input not saved

Posted by Martin Grigorov <mc...@e-card.bg>.
Hi,

you'll need some javascript to do this.

your link (alink) will have to call some JS function which will check
for changed inputs and if there is such input just call
event.preventDefault() to prevent the request to the LinkPage.class

On Wed, 2008-09-03 at 11:40 -0700, liza6218 wrote:
> Hi,
> 
> I'm trying to figure out the following, any help will be apreciated.
> 
> I have a form with 3 TextFields , a DropDownChoice and  a save button , 
> and a BookmarkablePageLink in the page.  
> 
> I need to add a javascript confirm window to the Link whenever any input
> changed without save (submit).
> and remove the confirm window when the change is saved.
> 
> 
> public aPage() {
>         form = new Form("form");
> 
> 	DropDownChoicequestion questions = new DropDownChoice("question", ...);
>         form.add(questions);
> 
> 	TextField answer1 = new RequiredTextField("answer1");
> 	TextField answer2 = new RequiredTextField("answer2");
> 	TextField answer3 = new RequiredTextField("answer3");
> 
> 	form.add(answer1);
> 	form.add(answer2);
> 	form.add(answer3);
> 
> 	form.add(new Button("save") {
>             @Override
>             public void onSubmit() {
> 	         saveChanges();
> 		 //remove the confirm window
> 	    }
> 	 }
> 
>         add(form);
> 	
> 	BookmarkablePageLink alink = new BookmarkablePageLink("alink",
> LinkPage.class));
> 	add(alink);
> }
> 
> 


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org