Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Any way to be notified of selected choices? #84

Open
vertex-github opened this issue Apr 3, 2014 · 6 comments
Open

Any way to be notified of selected choices? #84

vertex-github opened this issue Apr 3, 2014 · 6 comments

Comments

@vertex-github
Copy link

Igor - is there any way to be notified via a callback of a user selection in a Select2MultiChoice?

Ive got the component hooked up and working fine, complete with search function, but Im trying to sync the selected items in the MultiChoice after each user selection - is this possible?

@tgoetz
Copy link
Contributor

tgoetz commented Apr 3, 2014

No problem, simply do something like this:

Select2MultiChoice<String> multiChoice = new Select2MultiChoice<String>(
  "multiChoice", model, choiceProvider);
form.add(multiChoice);

multiChoice.add(new AjaxEventBehavior("change")
{
  @Override
  protected void onEvent(AjaxRequestTarget target)
  {
    // do something useful here
  }
});

@tgoetz
Copy link
Contributor

tgoetz commented Apr 3, 2014

Ah ok, if you'd like to sync on each change then you better do something like this:

multiChoice.add(new AjaxFormSubmitBehavior(form, "change")
{
  @Override
  protected void onSubmit(AjaxRequestTarget target)
  {
    // do something useful here
  }
});

@vertex-github
Copy link
Author

Thanks Tom! Will this submit the whole form or just the items in the MultiChoice?

@tgoetz
Copy link
Contributor

tgoetz commented Apr 3, 2014

This will submit the whole form. If you just want to submit the values of the MultiChoice, try org.apache.wicket.ajax.form.AjaxFormComponentUpdatingBehavior.

@vertex-github
Copy link
Author

I already tried that using:
emailsMC.add( new AjaxFormComponentUpdatingBehavior( "change" ){...}

The IModel isnt being updated as expected - hence this question :-)

@tgoetz
Copy link
Contributor

tgoetz commented Apr 3, 2014

Just tried AjaxFormComponentUpdatingBehavior in a quickstart and it works fine for me ...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants