Code Monkey home page Code Monkey logo

backbone-book's People

Contributors

antonjb avatar jasonkarns avatar juliocesar avatar mrhyde avatar nb avatar nicholasf avatar sirbrillig avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

backbone-book's Issues

Chapter "Views", part on placing 'tagName' and 'className' into a template - problem/question

Hello and thank you for the book!

I am trying to use your ideas and the part about getting rid of tagName and className and placing them inside the template sounded very nice.

But it works only when the View is added to the DOM by something/someone else. When the View needs to re-render itself (on Model's change) - it removes itself from the DOM and does not know how and where to insert itself again.

I am trying to render a list of items, where the user can click on the item and select/deselect it. I have the following template (Handlebars):

<li class="{{#if isActive}}active{{/if}}">
  <i class='fa-li fa'></i><span>{{name}}</span>
</li>

The isActive is a property on my ItemView class and I merge several properties from my ItemView with it's model creating a ViewModel which I pass to the template.

My ListView is rendering each item by instantiating ItemView and inserting it into a DOM - all is OK.

The problem is that after a click my view is removed from the DOM. Also the item's position in the list is lost.

Routing And Controllers - some text is unclear

Hi!

I am reading the page on Routing and Controllers and I cannot understand the following paragraph:

"With that, when navigating away from this screen and back to it, it'll seem as if my catalogue of books just rendered instantly. But for instance, if this screen loads only the 20 newest books introduced to my catalogue, and elsewhere in the screen the app displays a link to an older book of mine because someone left a comment in it."

From the 2nd sentence I cannot understand the meaning, or is it incomplete?

Thanks

Reading from views

Hi,

Thanks for the book, it's a great read (and I like the fact it's opinionated).

Throughout the book you advocate only writing to the DOM and "never" reading from it. My question is, if I never read from the DOM, how am I supposed to read data entered by the user in form elements (so I can subsequently update relevant model(s)).

Am I missing something?

Thanks
Rob

Chapter "Views", part about re-render on each change on a model

Hello and thank You for the book.

I would like to refer to "Rendering should be a destructive operation as far as what’s in the container element goes."

Say I have a nested tree view with some branches expanded. I guess the model for such a tree would be Model with ModelCollection as children property. And also I will have ModelView and ModelCollectionView for display. Now say I change a name/label of one of the expanded branches.

If I destroy this ModelView and re-render it - I should be able to reconstruct the whole sub-tree somehow. I need to know which branches were opened and which were closed, etc.

It becomes more complex if the sub-trees are dynamically loaded as the user expands the branches.

Just a thought...

Coffeescript/javascript toggle on spacebar

Which is used to navigate up/down pages.

This is a really stupid feature anyway. Either just use javascript, or have something you click. No one needs to toggle back and forth and read documentation how to.

Views - Model presenter object JS script issue

I was implementing a presenter object in a project follow the example that can be found on the view page: http://pragmatic-backbone.com/views.

The BookPresenter extends the ModelPresenter using Underscore's extend method

var BookPresenter = _.extend(ModelPresenter.prototype, {
    ...
});

This ends up adding the new methods (isPaid and isReturned) to ModelPresenter and assigning an object to BookPresenter. You can't then create a new instance of BookPresenter using the next example without getting an error as it isn't a function.

var presenter = new BookPresenter({model: this.model});

I'm not using coffeescript so haven't investigated that any further. I was able to get this working in my project doing the following.

var BookPresenter = function(options){
    ModelPresenter.apply(this, arguments);
};

BookPresenter.prototype = _.extend(BookPresenter.prototype, ModelPresenter.prototype, {

    isPaid: function(){
        ...
    },

    isReturned: function(){
        ...
    }

});

I haven't put this through as a Pull request because I'm not entirely sure if that's the best solution available but I'm happy to if it is.

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.