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
I recently using this feature on an expiremental durandal project and maybe someone find this helpful to knockoutjs.
In durandal, the function is inserted on viewEngine.js on line and the to convert all new bindings and the code became like this:
var newMarkup = templateEngineHelper(markup); //`markup` is the html node in string
var element = that.processMarkup(newMarkup);
This function will convert element attribute that has [] e.g. [text] or () e.g.(click) into html data-bind that will understand by knockout without changing behavior for existing data-bind.
New html binding with existing data-bind
<section>
<h3>
Features
<!-- you can use it along data-bind -->
<button data-bind="css:'btn btn-primary'" [text]="'Add Feature'" (click)="addFeature"></button>
</h3>
<ul [foreach]="features">
<li [text]="$data"></li>
</ul>
</section>
into
<section>
<h3>
Features
<!-- you can use it along data-bind -->
<button data-bind="css:'btn btn-primary',text:'Add Feature',event: { click:addFeature}" class="btn btn-primary">Add Feature</button>
</h3>
<ul data-bind="foreach: features">
<li data-bind="text:$data"> </li>
</ul>
</section>
I like this. Are HTML attributes with [] and () a.) broadly supported? and b.) likely to break HTML validators?
Unfortunately the spec and practice diverge on custom attributes, so I have reservations about putting this mainline... but it might be a great plugin.
For a, It was all valid attribute name, but I'm not aware in browser
support. All attributes with () and [] will convert to normal data-bind syntax so it will not render to DOM. And also for bindingHandlers with camel case, it is not supported, an alternative is
to use normal data binding. I'm thinking to have an array of all camel case bindingHandlers name and replace the value that it gets when getting
attributes with () and [].
I like this. Are HTML attributes with [] and () a.) broadly supported?
and b.) likely to break HTML validators?
Unfortunately the spec and practice diverge on custom attributes, so I
have reservations about putting this mainline... but it might be a great
plugin.
I recently using this feature on an expiremental durandal project and maybe someone find this helpful to knockoutjs.
In durandal, the function is inserted on viewEngine.js on line and the to convert all new bindings and the code became like this:
This function will convert element attribute that has
[] e.g. [text] or () e.g.(click)
into htmldata-bind
that will understand by knockout without changing behavior for existingdata-bind
.New html binding with existing data-bind
into
You can find code here.
The text was updated successfully, but these errors were encountered: