This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.
Since issue 231131 was introduced I can define properties of various types and enhance code completion in "with:", "foreach:", "text:", etc. directives. However I've just noticed that there is no way to influence "click:" - there is no way to register a function.
The modification of http://bits.netbeans.org/dev/javadoc/org-netbeans-api-knockout/overview-summary.html the Java API is probably straight-forward. Just define new method in Bindings: public Bindings function(String name) {...; return this; } which one can use to define a function: bindings.function("fnName"); however the question is what to generate as a resulting JavaScript? Will following be enough? var MyModel = { "fnName" : function() {}, "int" : 10 } Probably something for Petr to comment on.
Created attachment 152561 [details] Proposed fix
Please review method function(String name) in class Bindings. Thank you.
I'm not sure what exactly you are expecting in this case. If you want to have just fnName function in MyModel context, then it's ok. Probably you can also add some js doc? Like var MyModel = { /** * Generated by Knockout via bindings.function(.....) */ "fnName" : function() {}, "int" : 10 }
The suggested change looks OK to me. Thanks for pursuing it, Roman! Comments are in general missing in the API, one cannot assign them to primitive types neither to functions. I guess following check would also be useful: eng.eval("ko.value.myFunc1()") or assertEquals("function", eng.eval("typeof ko.value.myFunc1")); which would guarantee myFunct1 is really a function. > I'm not sure what exactly you are expecting in this case I'd like to see the function in the list of offered element in "click: " binding.
I have add a callback definition via Js Doc recently. It can probably helps you as well. See http://wiki.netbeans.org/NewAndNoteworthyNB81#.40callback .
If there aren't any objections, I'm going to integrate the patch (with enhanced test as suggested in comment #5).
Changeset: 4ee2b7f5d3d3 Author: Roman Svitanic <rsvitanic@netbeans.org> Date: 2015-03-20 18:06 Message: #251075: No way to expose callbacks through additional knockout model api. - fixed
Integrated into 'main-silver', will be available in build *201503240001* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress) Changeset: http://hg.netbeans.org/main-silver/rev/4ee2b7f5d3d3 User: Roman Svitanic <rsvitanic@netbeans.org> Log: #251075: No way to expose callbacks through additional knockout model api. - fixed Task #251075 - No way to expose callbacks through additional knockout model api.