Coder Social home page Coder Social logo

Comments (3)

gaby64 avatar gaby64 commented on August 27, 2024

change render in view object to

render: function(){
if(typeof this.view.format != 'string') {
this.view.$root = this.view.format;
this.view.format = this.view.format.html();
}
else if (this.view.$root.size() === 0) {
this.view.$root = $(this.view.format);
}
else {
this.view.$root.html( $(this.view.format).html() ); // can't overwrite $root as this would reset its presence in the DOM and all events already bound, and
}
return this;
}

and change

if (typeof args[1] === 'object') {
if(args[1].format)
$.extend(object.view, args[1]);
else
object.view.format = args[1];
}

from agility.

mahadevan-k avatar mahadevan-k commented on August 27, 2024

k, some basic stuff seem to work after a tweak to handle empty objects passed as the 'view' argument in the $$ constructors.

In render function:

if(typeof this.view.format != 'string' && !$.isEmptyObject(this.view.format)) {
this.view.$root = this.view.format;
this.view.format = this.view.format.html();
}
else if (this.view.$root.size() === 0) {
this.view.$root = $(this.view.format);
}

and

if (typeof args[1] === 'object') {
if(args[1].format || $.isEmptyObject(args[1]))
$.extend(object.view, args[1]);
else
object.view.format = args[1];
}

Will check more thoroughly as I implement code using the tweak.

from agility.

mahadevan-k avatar mahadevan-k commented on August 27, 2024

The view binding works great.

But if I did something like

<div class="agility article"><p data-bind="content">Lorem Ipsum</p>

And create the agility object using the above code, the model doesn't reflect the values, i.e.

article.model.get("content") is undefined

Is there a way to load the model from the DOM when the object is initialized?

from agility.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.