1

In this fiddle, I'm using X-editable. In the corresponding fiddle, I'm not able to make the below code working:

$('#practice').on('change', function() {
  alert(this.value);
});

Where am I going wrong?

Community
  • 1
  • 1
Zameer Ansari
  • 28,977
  • 24
  • 140
  • 219

1 Answers1

1

If you inspect the DOM when the editable is active (ie. the select is visible) you'll see that the select is not actually a child of the #practice span - it's in a sibling span named .editable-container. This is why your delegated event handler on #practice is not working.

That being said, if you read the X-Editable documentation there is an event you can hook to to achieve this directly without you needing to attach your own events - save.

Try this:

$('#practice').on('save', function(e, params) {
    alert(params.newValue);
});

Updated fiddle

Rory McCrossan
  • 331,213
  • 40
  • 305
  • 339