You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi ryan, I absolutely love this plugin and currently using it in developing a library for components.
However, I had to override to component binding handler in order to register the bindings i provide for the params attribute.
This is on the last part of init of the component handler
if(ko.bindingProvider.instance['registerBindings']){ko.bindingProvider.instance.registerBindings(currentViewModel);}else{thrownewError('Class binding provider must first be loaded to use custom component handler.');}ko.applyBindingsToDescendants(childBindingContext,element);
The way i declare the params for the binding class is like this
component: {params: {///any}}
I think it's kind of a bloat to overwrite the binding handler just to register the binding. Is there another way to extend the bindings without having to override? Thanks!
The text was updated successfully, but these errors were encountered:
@johndelrosario - one option for you, besides overwriting the binding, is to use an extensibility point around components that allows you to add your own component loader. For this scenario, we could add a loader that just implements a wrapper to the default loadViewModel function that tries to register bindings before creating a view model.
Perhaps something like:
ko.components.loaders.unshift({loadViewModel: function(name,config,callback){varwrappedCallback=function(createViewModel){// register binding before calling createViewModelvarwrappedCreateViewModel=function(params){if(params&¶ms.bindings){ko.bindingProvider.instance.registerBindings(params.bindings);}// create the viewmodel, as it normally would be createdreturncreateViewModel.apply(this,arguments);};callback(wrappedCreateViewModel);}// call the original loadviewModel without wrapper to interceptko.components.defaultLoader.loadViewModel(name,config,wrappedCallback);}});
Hi ryan, I absolutely love this plugin and currently using it in developing a library for components.
However, I had to override to component binding handler in order to register the bindings i provide for the params attribute.
This is on the last part of init of the component handler
The way i declare the params for the binding class is like this
I think it's kind of a bloat to overwrite the binding handler just to register the binding. Is there another way to extend the bindings without having to override? Thanks!
The text was updated successfully, but these errors were encountered: