I am so encouraged by all the people who are willing to submit issues and PRs for copy issues. That's such thankless work to begin with I'm amazed people bother. If you're in this channel and you've done that even for one letter THANK YOU.
[#41]title: Log css errors | Originally we were going to try to css escape the error and use fancy css to make it show up .before the body, but at least this will let people SEE the error till then. Right now it just silently fails.
lukekarrys
:)
I was just reading it
wraithgar
In all the talk about how to do fancy errors we forgot to at least put a logged error for now. ike was very confused
Guest71735 has quit
kamilogorek joined the channel
Guest34910 joined the channel
jordanlev
anyone have time/ability to answer some general ampersandjs questions?
lukekarrys
jordanlev: definitely. whats up?
jordanlev
Hi, thanks. I'm relatively new to front-end javascript MVC stuff (mostly back-end php guy and html+css+jqeury). Trying to untangle how the framework works. So far pretty good! But I can't figure out where common.js is
I used the CLI to generate sample project, and I see that the require() function is used all over the place. Conceptuially it makes sense to me... but I have no idea how common.js itself is being loaded anywhere?
lukekarrys
commonjs is the module style, if that makes any sense
jordanlev
huh, so common.js is not a library (like require.js)... just a way of structuring code?
lukekarrys
under the hood of moonboots we use browserify, which translates all those require statements so it knows what module you are referring to
legastero has quit
yeah
unbracketed has quit
so require('underscore') will pull underscore from node_modules since it is not a relative path
jordanlev
where is the rquire() function defined?
lukekarrys
from browserify
Direct from the browserify page
"Browsers don't have the require method defined, but Node.js does. With Browserify you can write code that uses require in the same way that you would use it in Node."
Aria
Every module is implicitly wrapped in (function(require, module, exports) { the module })(aRequireForThatModule, theModuleObject, theModuleObject.exports);
jordanlev
I'm very unfamiliar with node/browserify, so pardon my ignorance...
where is browserify loaded etc>
?
nickbytes joined the channel
lukekarrys
no worries :) I remember being in the same place
jordanlev
From what I can tell, the very first code executed when a request is made is client/app.js
first line there is var _ = require('underscore');
legastero joined the channel
but obviously other things have run before we get there, otherwise how would the server know what the require() function is?
lukekarrys
so browserify isn't loaded, but all the code you write is run through browserify which does all the wrapping that Aria just mentioned
and out comes a single JS script which is included on the page
skipped over that page, will look more closely now, thanks!
Aria
Nice!
wraithgar
If that doesn't answer your question, the fault lies in that page not with you.
jordanlev
Well if you want my opinion as someone learning this stuff, to me it helps to be shown a very explicit path of code execution. Browser sends http request to server, then what exactly happens. I think this is one of the reasons PHP became so popular, because the mental model of how code is executed is dead-simple.
BTW, that is not a criticism of your docs... overall they are FANTASTIC
especially humanjavascript
read that last night, was enlightening. Have the same excitement about ampersand that I did when I first discovered Rails 10 years ago
wraithgar
That's a tall order cause of browserify magic. You have to think of it using commonjs conventions then it's magically turned into something the browser will run.
jordanlev
Another question, probably on the other end of the abstraction spectrum... (and this is probably more about JS front-end MVC in general, not ampersand specifically)...
I want to build a basic CMS interface. On the left side of the screen is a list of all pages in the site (just a title and an id)...
on the right side of the screen, an "edit this page" form will appear when one of the pages on the left list is clicked.
Seems like the naive architecture is to load ALL data about ALL pages in models and a collection, then have the list on the left output from that collection, and the edit form on the right edit the model from that collection.
BUT this is very wasteful... if there are 300 pages in the site (hence 300 records), no need to load all that data because user will probably just be editing 1 or 2 pages this session.
So would I have 1 collection with 1 type of "basic" model for the list (the basic model is just page id and page title), then the "edit form" on the right doesn't tie into that collection, but instead loads a separate "page" model with the FULL data for the page (all the content fields, etc.)?
Hope my wall of text question makes sense :)
rhodesjason has quit
rhodesjason joined the channel
lukekarrys
I dont see a problem with doing it that way
Aria
I think it does. That's a pattern I've done in Backbone, and it worked well.
lukekarrys
click a link in the sidebar -> get id for page -> instantiate a model with that id and fetch it
Aria
Also tried "completing" models -- initiating a request for the rest of the data when I loaded it. So it came from a limited collection first, but then would be fetched and completed from a single API later on
jordanlev
Okay, so my confusion is that when everyone talks about how great backbone etc. is, it's because "it keeps your view in sync with your model" etc... But in this architecture, now that list on the left is not synched witht he model on the right.
Aria
I'm not sure how that translates to Ampersand.
jordanlev
In other words, if user clicks on a page on the left, then changes the page title on the right, how do I tell the list on the left to now update the title for that 1 record that was just updated?
HenrikJoreteg has quit
Guest34910 has quit
@Aria, interesting... that makes sense (not sure how I'd implement it yet, but I like the conceptual simplicity)
Aria
In backbone, it was pretty much "model.fetch(); model.on('sync', ... enable the UI);"
(maybe making fetch conditional on whether it's complete already)
rhodesjason has quit
jordanlev
okay, well thank you both so much for your time.
lukekarrys
no problem! come back with questions anytime!
jordanlev
Things stil a little murky, but getting a bit clearer. When I have some time I'll build a real project with ampersand, should make lots of things more apparent