Replies: 1 comment
-
sure, you can use
function(input) {
var data = {};
data[self.settings.labelField] = input;
var key = input;
if ( self.settings.formatValueToKey && typeof self.settings.formatValueToKey === 'function' ) {
key = self.settings.formatValueToKey.apply(this, [key]);
if (key === null || typeof key === 'undefined' || typeof key === 'object' || typeof key === 'function') {
throw new Error('Selectize "formatValueToKey" setting must be a function that returns a value other than object or function.');
}
}
data[self.settings.valueField] = key;
return data;
}; So, you can copy/paste this into your function(input) {
var data = {};
data[self.settings.labelField] = input;
var key = input;
if ( self.settings.formatValueToKey && typeof self.settings.formatValueToKey === 'function' ) {
key = self.settings.formatValueToKey.apply(this, [key]);
if (key === null || typeof key === 'undefined' || typeof key === 'object' || typeof key === 'function') {
throw new Error('Selectize "formatValueToKey" setting must be a function that returns a value other than object or function.');
}
}
data[self.settings.valueField] = key;
// ------- Your ajax here for example
$.ajax({
method: 'POST',
data: 'value=' + key // Not sure key is correct value, verify
})
.then(...)
.catch(...)
return data;
}; |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
I have not been able to successfully implement the following:
I am using Selectize with DataTables.net.
Can I create a new item (create: true) and have it added to my (mySQL) database?
Thanks!
Beta Was this translation helpful? Give feedback.
All reactions