It seems inside the DataProcessor, the store does not have an attachEvent() method. Actually, it only has a “driver” property. Shouldn’t it be a DataStore instance and have that method ? I need to get an id for the view in order to lookup on the database, and getting the DataProcessor seemed to be my choice, but I’m stuck.
If you need to get id - you can use view.config.id, dataprocessor can be used if you want to handle data saving operations, but it is unnecessary for data loading.
load: function(view, callback) {
var db = new PouchDB(this.source, config);
var doc = db.get(view.config.id, function(){
view.parse(doc.data); //load data in component
});
}
I was aware of view.config.id, but that’s “$form1”. I think I’d need to access the serialized data from the form (actually, It’s just a login form and I need to match its only two fields: login and password).
I’ve tried view.serialize() as well, but that function isn’t defined… how can I access the view data, and customize serializing so that {“login”: “xxxx”, password: “yyyyy”} gets mapped to {"_id": “xxxx”, password: “yyyyy”} as pouchdb expects me to search ?
you can use view.getValues() - it will return json object with all data from the form.
As for customization - you can use custom code to update json object, or just use name:"_id" for the login field in the form. In such case form will return value in the way necessary for PouchDB
Once again, thank you for your time. I have the same error with or without the ‘save’ parameter. At the moment I do not use save, as I implement my own form save function:
{ view: ‘button’,
label: ‘Save’,
type: ‘form’,
click: function(){
var form = this.getFormView();
var v = form.getValues();
Meteor.call(‘updateUser’, {
name: v.name,
surname: v.surname
});
}
This works. It does update the Meteor MongoDB. But if I change the MongoDB manually via a shell, the expected on my view does not happen but does get triggered, because I get that error (TypeError: this._settings.store.attachEvent is not a function).
My webix view is defined as follows (I use … for ommiting unecessary code):