pablovallejo / gillie Goto Github PK
View Code? Open in Web Editor NEWJavascript Microframework inspired in BackboneJS
Home Page: http://pablovallejo.github.io/gillie/
License: MIT License
Javascript Microframework inspired in BackboneJS
Home Page: http://pablovallejo.github.io/gillie/
License: MIT License
Hi,
I'd like to know if we can access to the response HTTP code. Here is the snippet from the jQuery AJAX documentation.
$.ajax({
statusCode: {
404: function() {
alert( "page not found" );
}
}
});
Thx!
Hi,
Got a form with a specific action, I would like to get this action with .attr('action')
. Then I have something like "http://domain.com/action".
I don't want to hard code the URL in the JS files.
But Gillie adds also the base URL, even if I put url: '/'
in the model. So my URL becomes : "http://domain.com/http://domain.com/action".
Is there any way to avoid this?
Thank's!
Nice work! I found the models/views/handlers/events
links in the first paragraph are not correct. I guess they might be http://pablovallejo.github.io/gillie/xx/
instead of http://pablovallejo.github.io/xx
ใ
Hi,
I think there is a lack of examples in your doc. I'm a bit of lost. Here is my test code:
'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();
'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();
'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,
'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
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!
because you do not add integration continues with travis-ci?
It could be cool to have a TodoMVC version of Gillie.
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
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.