[Dojo-interest] Multiselect question

Robert Coup rcoup at dojotoolkit.org
Thu Aug 7 22:01:52 UTC 2008


On Fri, Aug 8, 2008 at 8:22 AM, Jette Derriche <jni at nerdgirl.dk> wrote:

> I am trying to create a couple of multiselects with a pair of ">" "<"
> buttons between them. Just like the ones shown at the top of this page:
>
>
> http://archive.dojotoolkit.org/nightly/dojotoolkit/dijit/tests/form/test_MultiSelect.html
>
> The above test works fine in my browser, so I tried to copy relevant
> code from the page to the site I am developing. But whenever I press a
> button to move and item from one box to the other, the page is reloaded,
> and nothing is moved... very strange. This is my code. Hope someone can
> explain this:


The form is being submitted... the test above submits to "#" so the page
doesn't reload, but yours is submitting somewhere real :)

// listen to the "move items" buttons
>  dojo.query("button.switch")
>  .connect("onclick",function(e){
>    switch(e.target.id.toString()){
>      case "airportLeft" :
> dijit.byId("airport2").addSelected(dijit.byId("airport1")); break;
>      case "airportRight" :
> dijit.byId("airport1").addSelected(dijit.byId("airport2")); break;
>    }
>  });


So you could move the buttons outside the <form>, or change the above code
to:

dojo.query("button.switch").connect("onclick",function(e) {
  switch(e.target.id.toString()){
    case "airportLeft" :
dijit.byId("airport2").addSelected(dijit.byId("airport1"));
break;
    case "airportRight" :
dijit.byId("airport1").addSelected(dijit.byId("airport2"));
break;
  }
  // cancel the click event so we don't submit the form.
  dojo.stopEvent(e);
});

hth,

Rob :)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://turtle.dojotoolkit.org/pipermail/dojo-interest/attachments/20080808/a2ab9e49/attachment.html 


More information about the Dojo-interest mailing list