So I'm sure I'm not the first person who's ever tried to do this, but I can't find any examples that match what I'm trying to do so here I am.
I have a Knockout custom binding that is defined as such.
ko.bindingHandlers.table = {
init: function (element, valueAccessor) {
value = ko.unwrap(valueAccessor());
//Create a table
};
The goal is to minimize what a user who wants to create a table has to know about javascript. The HTML that I'd like them to supply is something like:
data-bind="table: foo, columns: ['id', 'first name', 'last name', ect...]"></table>
I want to be able to specify the columns in an array-like format (again, trying not to use any JS). I'm aware that I could do something dumb like col1: 'id', col2: 'first name' but I'd rather have an object / array that I can easily just do a .length() of when I go to make my table.
I do have a work-around working with data- using Jquery, but I'd rather do something like this if I can.
Last but not lease, I'm assuming that I'd gain access to the object through the allBindings accessor, if I'm mistaken by that please let me know. Thank you in advance.