Skip to content

Can I have input fields sortable? #53

Closed
jogaco opened this Issue Dec 3, 2013 · 3 comments

2 participants

@jogaco
jogaco commented Dec 3, 2013

Congrats for this great plugin.

However, I'm having problems integrating it in my form.
I have an input form with dynamic fields distributed in table rows.
I'd like to have my rows sortable and at the same time enter my input data when focusing fields with a mouse click.

I had everything working fine, but the mouse click did not activate focus on input fields. Then I saw an issue which could be related to this: #17

Is it possible to have sortable on table rows with input fields and still have input focus when clicking with the mouse?

I've prepared a quick jsfiddle: http://jsfiddle.net/jogaco/m3h9V/10/

@johnny
Owner
johnny commented Dec 3, 2013

There are two options:

  1. Use a sort handler
  2. Override the onMousedown function to check if the the clicked element is an input field and return false

Option 2 is not supported yet. You would have to change the ContainerGroup.prototype.dragInit to handle return values of onMousedown and do nothing on false

Pull requests are welcome

@jogaco
jogaco commented Dec 3, 2013

Thanks for the tips.
I just had to add my own onMouseDown handler:

onMousedown: function ($item, _super, event) {
if (event.target.nodeName == 'INPUT') {
return false;
}
event.preventDefault();
return true;
}

Should this be the default implementation? I could do a pull request with this.

@johnny
Owner
johnny commented Dec 3, 2013

Oh right, I already implemented handling return values...

Time for a new release.

Please submit a pull request, but use the implicit returning of nil, i.e.

onMousedown: function ($item, _super, event) {
  if (event.target.nodeName != 'INPUT') {
    event.preventDefault();
    return true;
  }
}
@johnny johnny closed this in 474b9a0 Dec 4, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.