x-editable has the option()
method which is used to set a new option. params
is one of the options and happens to be an object, and instead of replacing params
with a new object, I just want to add a property to the existing params
object. Below is my attempt, but I am inadvertently overwriting params
and not adding a new property as desired.
http://jsfiddle.net/fo1susa1/
$(function() {
$('#name').editable({
url: '/echo/json/',
pk: 123,
params:{a:1,b:2}
})
.on('shown', function(e, editable) {
editable.option('params', {c:3});
});
});
You can add a property to the existing params object like this:
$(function() {
$('#name').editable({
url: '/echo/json/',
pk: 123,
params:{a:1,b:2}
})
.on('shown', function(e, editable) {
editable.options.params.c = 3;
// editable.options.params is now {a: 1, b: 2, c: 3}
});
});
Hope this helps.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With