Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Note that this update brings significant feature improvements with corresponding changes to the implementation. For normal usage patterns these do not correspond to breaking changes. However there could possibly be breaking changes on a few advanced scenarios. If appropriate, please file issues if breaking changes are observed. See also the samples and unit tests for changes that take advantage of new features below. New features and improvements - {{: xxx}} can now be used without arguments, so {{:}} is equivalent to {{:#data}}. This is a similar pattern to {{for}} {{include}} etc. - autoBind feature for custom tags allows a custom tag without argument to bind to current data context, so {{mytag/}} is equivalent to {{mytag #data/}}. This is achieved by setting autoBind: true on the tag definition. - Can now define a converter for the first arg on any tag - custom or built-in. e.g. {{for myarray convert=~reverseArray}} or {{mycustomtag name convert='someRegisteredConverter'/}} or <div data-link="name convert=formatName" /}} (in this example the person object has a name property and a formatName method) - Similarly any tag with two-way binding can have a convertBack converter: e.g. <input data-link="name convert=~SomeHelper convertBack=SomeMethodOnDataObject" /> or {^{slider speed convert=~fromMphToKmH convertBack=fromKmHtoMph/}} or: {^{myTextBoxTag convert=~myCnvtHelper convertBack='myregisteredConverter'/}} - Support for triggering updates to the tag based on dependencies declared for the converter as well as dependencies declared on the tag itself. There is also a new $.view.sub.getDeps() helper function for combining multiple dependency declarations - used internally to implement the above feature. - Improved support for rendering arrays without iteration: render(array, helpers) will iterate over the array, but you can now pass a 'noIteration' boolean. So render(array, true) renders anv array without iteration, and similarly, render(array, helpers, true) now renders an array without iteration while passing in helpers. Within methods and events of custom tags: tagCtx.render() renders against the current data object, tagCtx.render(someArray) iterates over the array tagCtx.render(someArray, true) or tagCtx.render(someArray, helpers, true) renders without iteration. - In a custom tag, a template can now be assigned (determined dynamically) in the init method simply by setting: this.template = templateObjectOrMarkupString; It is no longer necessary to write: this.template = tagCtx.tmpl = templateObjectOrMarkupString; - Support for declaring event handlers directly on tags or data-link expressions: {{anyTag onXxx=myXxxHandler /}} This can be used for standard event handlers such as onUpdate, onBeforeChange etc. e.g. <textarea data-link="text onUpdate=updateMethodOnViewModelObject"></textarea> - There is a new helper utility function for validation of HTML markup in JsViews: $.views.utility.validate(markupString) This could be used in the following example: $.views.helpers("validateMarkup", $.views.utility.validate); <textarea data-link="text onBeforeChange=~validateMarkup"></textarea> - Improved error message if JsViews or JsObservable is loaded without jQuery Bug fixes: - Fix for BorisMoore/jsrender#231 - Fix for BorisMoore#198 - Fix for BorisMoore#231 - Fix for a memory leak issue - Fixes for some issues with radio buttons and with multiselect - Fixes for bugs in some samples
- Loading branch information