Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

X-Editable: Attach event to data change

How to attach events to any data changes in fields done using XEditable? If not if there is any other plugin that allows that kind of behavior?

like image 800
Sumit Shrestha Avatar asked Feb 28 '14 05:02

Sumit Shrestha


2 Answers

I am using Angular-xeditable, And i am able to bind events and add other attributes too. Add e-onChange="alert('I am Fired')" to your needed HTML Tag. For Example:

<a href="#" editable-text="user.name" e-onChange="alert('I am Fired')" e-style="color: green" e-required e-placeholder="Enter name">

http://jsfiddle.net/cg3pLmed/

And by JavaScript

$('#username').on('save', function(e, params) {
     alert('Saved value: ' + params.newValue);
});

Fired when new value was submitted. You can use $(this).data('editable') to access to editable instance. Check with the Events in the following link http://vitalets.github.io/x-editable/docs.html

like image 173
Ramesh Avatar answered Sep 22 '22 17:09

Ramesh


You can use e-ng-change to add a callback like this:

<span editable-select="user.status" e-name="status" 
    e-ng-change="onStatusChanged($data)" 
    e-ng-options="s.value as s.text for s in statuses">

Here is a fiddle where the Status selectbox will fire the Controller method onStatusChanged:

http://jsfiddle.net/NfPcH/9713/

like image 28
andzep Avatar answered Sep 26 '22 17:09

andzep