Open jlaustill opened 8 years ago
This seems to be doing the trick
ko.bindingHandlers.tagsInput = {
init: function (element) {
$ (element).tagsInput ({
interactive: true,
delimiter: [","], // Or a string with a single delimiter. Ex: ';'
removeWithBackspace: false,
minChars: 0,
maxChars: 1000,
width: "100%",
onChange: function (elem) {
avm.tags ($ (elem).val ());
}
});
}
};
with this binding
<textarea data-bind="tagsInput: true" rows="4"></textarea>
and this mapping to the viewModel
var avm = new AppViewModel (data);
Not sure if this is the best approach or not.
I'm thinking this isn't a bug, but more just a lack of compatible binding. I have a simple textarea with a tags id that I use tagsInput on, like
The plugin works fine and adds the tags functionality, but it's not binding to my observable in ko. So if I do
I am getting back the proper delimited string, but
gives me nothing. I'm sort of new to KnockoutJS, but my understanding is that I would need to write a custom binding to work with tagsInput. I'm wondering if anyone has done this and has an example, or if I'm on my own, or if I'm just totally going about this the wrong way? I'm all ears for any suggestions anyone has whatsoever :)