Giter Site home page Giter Site logo

guides's People

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

Watchers

 avatar  avatar  avatar  avatar  avatar

guides's Issues

Set Marionette Version

Since Marionette 3 is now out, we should update the version numbers throughout the guide to force version 2.4.7. This will prevent newcomers from being confused.

Validation Result Is Ignored

With these changes, we can now refuse to add an item unless it passes validation. We could also display error messages if validation fails by binding the invalid event in modelEvents. You can see how we've set our fields to blank fields on the model and also in the ui hash. If we start having more and more fields, you can see how this would quickly become unmanageable. Surely we can just clear the form when the model is cleared?

Validation Result Is Ignored

You provided the validation function in model, but in driver.js, you still add the model anyway, regardless of the validation outcome. I think you should wrap the last 2 lines inside onAddTodoItem() inside an if statement, such as if (this.model.validationError === null)

Submitted by @charliegdev

Missing module

We'll be using the layout described in the introduction, so let's move the bulk of our view code into views/layout.js and rejig it a little:

bundle.js:17800 Uncaught Error: Cannot find module "../models/todo"

models are not defined in this or prior sections in the tutorial

/cc @scott-w

submitted by @iampeterbanjo

Analysis: Behaviors

Hey,

I just found myself with a bit of free time and agreed to read over some sections for @jdaudier. Here are my thoughts on the Behavior's section:

Sharing common view Behavior / What is a Behavior?

  • The code example is slightly inconsistent. The first snippet uses triggers without a behavior. Then the "same code" is represented within a behavior, but now uses events. I think that this detracts from the intention of the example.

Listening to View events

The example itself here is good for conveying what a Behavior is, but I have some concerns about the correctness of the example. Is it really a view's job to be telling its collection to mark models as newlyAdded? What if there was no view -- should things simply stop being marked as newly added? What if the collection was shared between multiple views? etc... This entire example feels like a job for Cocktail not Behaviors.

I think using an example that's a bit more presentation-specific could be beneficial. Perhaps doing a 'mouseover/mouseout' + showTooltip concept. In fact, I see a tooltip example in the list of extended examples. I feel like this would be a better introductory concept, but maybe others feel differently.

Defaults

All of the defaults example stuff seems fine. Personally, I feel like behaviors should use a different term than 'defaults' since they're not accessed in the same way as BB.Model defaults. This has led me to confusion in the past, but that's not super related to the docs.

Misc

One thing I would've liked to see more talk on is an issue I raised in Mn issues a while back: marionettejs/backbone.marionette#2784. Even if the guide doesn't suggest one pattern or the other... I think it would be prudent to make people aware of their different options for view/behavior interactions. Passing methods down into the behavior vs having the behavior emit events which come back up.

Additionally, I didn't see any mention of nesting behaviors -- which is certainly possible :)

Overall, read well and had a solid amount of examples. I don't really expect people to take the examples at face value, but it would be nice to have a higher level of confidence in them just in case people do copy/paste the examples and assume they're best practice.

template value is missing 'require' for the ToDo LayoutView

In the code snippet below, the template value is missing 'require' for the ToDo LayoutView

https://marionette.gitbooks.io/marionette-guides/content/en/getting_started/tutorial/firstview.html

Our list of items is really a collection, so we'll use the Backbone.Collection to model it. We'll also use a view that specializes in rendering lists of data - the CollectionView. Back in our driver.js file, we're going to use a couple of views:

Originally submitted here: https://www.gitbook.com/book/marionette/marionette-guides/discussions/2

/cc @scott-w

Introduction makes no sense

A couple of minor issues with the introduction:

  • The first link to the reference docs is broken
  • "Where do I start" is duplicated

Form Validation (Assignee / Text inputs)

Need to update the final code for chapter # 2 and in the appendix so the form validation will work. Adding an if statement in layout.js will work:

onChildviewAddTodoItem: function(child) {
    this.model.set({
      assignee: child.ui.assignee.val(),
      text: child.ui.text.val()
    }, {validate: true});

    if (this.model.isValid()) {
      var items = this.model.pick('assignee', 'text');
      this.collection.add(items);
    }
  }

Testing Guide

We need to include a recommended testing style for the Guides that gets users off the ground.

Update for Marionette 3.0

We need an updated version of the book for Marionette 3.0.

We could do this by forking the book and publishing a separate version. We would then have to handle linking from the website.

Typos found while adapting the chapter 2 tutorial

https://marionette.gitbooks.io/marionette-guides/content/en/getting_started/tutorial/layouts.html

Near the end in layout.js onChildviewAddTodoItem still refers to this.ui, but the ui has been refactored out into the form view at this point. To get this to work I needed to add a parameter to the onChildviewAddTodoItem method and access ui via that object.

This also appears in the summary code:

https://marionette.gitbooks.io/marionette-guides/content/en/appendix/getting_started/tutorial/todo_app.html

Don't trigger `show`

The tutorial currently has:

var App = new Marionette.Application({
  onStart: function(options) {
    var todo = new TodoView({
      collection: new Backbone.Collection(options.initialData.items),
      model: new ToDoModel()
    });
    todo.render();
    todo.triggerMethod('show');
  }
});

App.start({initialData: initialData});

In v3 rendering and "showing" your own view would be greatly discouraged, and I don't think you should really do it in v2 either.. some views will not know they are attached if a region is not involved.

I understand why we got to this place because we were moving away from Application.Regions and because there was no clear place to start a LayoutView, but I would still say that this is a better pattern in v2. Then the change in v3 is to change the regions hash to a simple region: '#app-hook'

I don't know if it is worth the effort of the change, but I've seen this question a bit lately in gitter and SO.

var App = new Marionette.Application({
  regions: {
    'appRegion': '#app-hook'
  },
  onStart: function(options) {
    var todo = new TodoView({
      collection: new Backbone.Collection(options.initialData.items),
      model: new ToDoModel()
    });
    this.getRegion('appRegion').show(todo);
  }
});

App.start({initialData: initialData});

Error trying code from guide

I was trying the webpack config for 'Bundled jQuery' method in https://marionette.gitbooks.io/marionette-guides/content/en/getting_started/installing_marionette.html. But it's giving me the following weird error on running webpack. I am using the same config suggested in the guide.

$ node_modules/.bin/webpack .                                                                                                         !10297
Hash: 828209a9b8c5230cb7de
Version: webpack 1.13.3
Time: 48ms
    Asset     Size  Chunks             Chunk Names
bundle.js  1.61 kB       0  [emitted]  main
   [0] multi main 40 bytes {0} [built] [1 error]
   [1] ./app/driver.js 0 bytes {0} [built]

ERROR in multi main
Module not found: Error: Cannot resolve 'file' or 'directory' /home/gokul/root/mobme/worklight/fubar in /home/gokul/root/mobme/worklight/fubar
 @ multi main

Code License

While it should be obvious that readers could copy and paste code, we should include an explicit license grant in the text to provide that extra confidence.

With that in mind, the choices would be:

  • MIT
  • 2 or 3 clause BSD
  • Public Domain grant
  • CC0 license (current)

Are there any preferences?

Using ES6

A quick question for discussion:

With ES6 starting to gain popularity through Babel, should the Guides use it as the basis for code samples? I'm happy to throw in the additional configs for Webpack to make it work.

A counterpoint is that it's still not natively supported, and it could possibly add another concept for readers to grasp that prevents the Guide from being useful.

I'm open to suggestions and I'd like to open it to the floor before I get too committed to a coding style for the v3 Guide.

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.