ukijs + knockoutjs seems like a good match

134 views
Skip to first unread message

Greg

unread,
Mar 9, 2011, 8:42:57 PM3/9/11
to ukijs
Just found this framework today, and let me say I'm impressed. I've
been working on a desktop style web app for my company and been using
a mixture of knockoutjs and jquery templates to build the whole
thing. Have you looked at utilizing knockoutjs to do the binding in
your views instead of writing "glue" code in your controllers via the
model events? I think if these two projects paired up it would be
pretty amazing.

I put together a hack demo showing the two interact here http://jsfiddle.net/7G2h5/



It would be amazing if you could define something like the following
in your view code
uki({
view: "Button", data-bind: "text: buttonText, click: buttonClicked",
rect: "120 80 180 24"
}).attachTo( document.getElementById("test") );

var viewModel = {
buttonText: ko.observable("hello world"),
buttonClicked: function(){
alert(this.buttonText());
}
};
ko.applyBindings(viewModel);

voloko

unread,
Mar 9, 2011, 9:15:44 PM3/9/11
to ukijs
In 0.4 uki does Bindings on views. Since I do not need to support
direct biding to dom nodes it can be done in a much simpler manner
then knokout does it now. With all the library core (bindings,
selectors, events, templates, builder etc) being under 10k gziped.

API now looks like this:

// create an observable model
var Model = uki.newClass(Observable, {

// with observable property
text: uki.Observable.newProp('text')
});
var m = new Model();

// bind default Text's default 'value' property to model's 'text'
uki({ view: 'nativeControl.Text', binding: { model: m, modelProp:
'text' });


On Mar 9, 5:42 pm, Greg <greghrobe...@gmail.com> wrote:
> Just found this framework today, and let me say I'm impressed.  I've
> been working on a desktop style web app for my company and been using
> a mixture of knockoutjs and jquery templates to build the whole
> thing.  Have you looked at utilizing knockoutjs to do the binding in
> your views instead of writing "glue" code in your controllers via the
> model events?  I think if these two projects paired up it would be
> pretty amazing.
>
> I put together a hack demo showing the two interact herehttp://jsfiddle.net/7G2h5/

Greg

unread,
Mar 9, 2011, 11:14:52 PM3/9/11
to ukijs
That looks promising. How developed is your observable implementation
in terms of support for arrays? Can you bind an array to a list or
grid control? Also, one of the great things about knockout is the
ability to write custom bindings that let you tie into binding events
and do interesting things like cause animations to activate or dialogs
to launch when the value changes.
Finally the obvious, when is 0.4 gonna be available? Thanks, again
appreciate what you've been doing.

Johan Rydberg

unread,
Mar 10, 2011, 5:57:15 AM3/10/11
to uk...@googlegroups.com, voloko
What about the cases where you do not have the model at hand when
the view is created?  

I suppose some kind of proxy could be put in place, just like
controllers in Cocoa.

Vladimir Kolesnikov

unread,
Mar 10, 2011, 3:10:20 PM3/10/11
to uki google group
0.4 should be ready in 2 weeks. Sooner if you guys help.

Yes you can extend the Binding class. view.binding(x) is just a shortcut
to new uki.Binding({ view: view, model: m })
https://github.com/voloko/uki/blob/master/src/uki-core/binding.js
However I'm not sure why you want to use bindings to create custom
responses. It's often faster to write an event handler then a custom
binding.

It's more complex with list/grid controls. I'll provide a simple api for
common cases. Though lists are tough beasts, so for some cases you'll
still have to resort to manual coding.

Reply all
Reply to author
Forward
0 new messages