Giter Site home page Giter Site logo

gillie's Issues

Add Travis-ci

because you do not add integration continues with travis-ci?

Lack of understanding with controller <=> others and model <=> view

Hi,

I think there is a lack of examples in your doc. I'm a bit of lost. Here is my test code:

Controller (handler)

'use strict';

// Handlers are used to listen for DOM events, get data from them
// and then route that data to a controller, view or model.

var Controller = Gillie.Handler.extend({

    initialize: function() {
        console.log('controller ok');
    },

    events: {
        'click .intro-text': 'showPost'
    },

    showPost: function(e) {
        console.log('showPost'); // OK
    }

});

var demoController = new Controller();

Model

'use strict';

// Models take care of talking to the server by making AJAX requests
// and then triggering events so that views that are listening to them
// can do actions with the returned data.

var Model = Gillie.Model.extend({
    // Default attributes (use get(), set(), unset())
    defaults: {
        'alias': 'none',
        'picture': 'default.jpg'
    },

    url: '/',

    // Run on instantiation
    initialize: function() {
        console.log('model ok');

        this.save();
    },

    save: function() {
        this.Post('person/', 'post.create');
    }
});

var demoModel = new Model();

View

'use strict';

// In Gillie, views are taken care of affecting DOM elements,
// that means, they subscribe to models events, when these events
// are triggered, views print the new data, of show feedback, etc.

var View = Gillie.View.extend({
    initialize: function() {
        console.log('view ok');

        // Listen for model 'post.create' event
        demoModel.on('post.create', this.onCreate);
    },

    onCreate: function( modelInstance, response ) {
        console.log('onCreate');
    }
});

var demoView = new View();

So,

  1. I don't understand how to communicate between the controller and the model or view.
  2. My 'post.create' event in the model doesn't fire the listener (in the view), why?

I appreciate your work and I'd like to use Gillie!

Bests

Converting circular structure to JSON: Post request triggered manually

Hi,

My view:

/**
* Constructor
*/
initialize: function() {
    /**
    * Client-side validation on the sign-in form
    */
    $('#contact_form').parsley().subscribe('parsley:form:validate', function (formInstance) {
        formInstance.submitEvent.preventDefault();

        if(formInstance.isValid()) {
            HomeModel.sendMessage();
        }
    });

    HomeModel.on('messageSent', this.messageSent);
},

My model:

/**
* Sends a message
*/
sendMessage: function() {
    this.Post('contact/send-message', 'messageSent');
}

Got Converting circular structure to JSON error on line: 399 (on JSON.stringify());

I'm stuck here.

By the way, how to tell to the POST request which data I wan to send?

Thank's!

Data sent over HTTP: deal with both string and object

Hi @PabloVallejo,

Sometimes you want to send all your form by HTTP, so this is correct:

submit: function () {
    this.Post('/something', 'form.sent', { data: $('form').serialize() });
}

Sometimes you want to send specific values:

submit: function () {
    // Option 1
    // ------------------------------

    var data = {
        a: 'b',
        c: 'd'
    };

    // The idea is to skip this:
    data = decodeURIComponent($.param(data));

    // Option 2
    // ------------------------------

    var data = 'a=b&c=d',

    this.Post('/something', 'form.sent', { data: data });
}

The Option 1 is more clear especially if your values are not statics. This could be achieved by checking the variable type.

What do you think?

Bests

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.