Register a SA Forums Account here!
JOINING THE SA FORUMS WILL REMOVE THIS BIG AD, THE ANNOYING UNDERLINED ADS, AND STUPID INTERSTITIAL ADS!!!

You can: log in, read the tech support FAQ, or request your lost password. This dumb message (and those ads) will appear on every screen until you register! Get rid of this crap by registering your own SA Forums Account and joining roughly 150,000 Goons, for the one-time price of $9.95! We charge money because it costs us money per month for bills, and since we don't believe in showing ads to our users, we try to make the money back through forum registrations.
 
  • Post
  • Reply
nexus6
Sep 2, 2011

If only you could see what I've seen with your eyes
I've been working mainly as a PHP developer but recently I've taken a dabble in javascript SPAs. So far I've written:
  • an application for managing debts/who paid for lunch among developers
  • a multi-step registration form that stores data offline then AJAXs it later to a server
  • an interactive map using LeafletJS and markers loaded from a database

Each of these has basically been an index.html file with all the markup shown/hidden as necessary and a big 'ol script.js file full of jQuery for manipulating the HTML. The closest I've come to organizing these is writing functions instead of keeping everything in $(document).ready();

I've been looking at Backbone as a way to better write these apps but it feels like a leap to me, like I'm missing an intermediary step. A lot of the tutorials and guides I have read have been 'this is the syntax for a View' and I don't really feel like I know what code should be a view, what functions show go in these Views and which should go in Models e.t.c. I feel like I'm learning how to make the same todo app again and again without really understanding how to think about my app in a 'Backbone' way.

Are there any resources I should read about OO jQuery before attempting to continue learning Backbone? I have gone through this article but still feel a little lost, like why are there two status classes with add() methods, one that just calls the other? Maybe it's just because Backbone is overkill for that really simple example? The fact the the code diffs are not formatted also make it quite difficult to read.

FWIW I've found tut+ tutorials to be a mixed bag: some are genuinely interesting and informative whilst others, like the Backbone Contacts Manager tutorialare pretty badly written, contain typos in the code that prevent it running, skip over a lot and don't match the code in the downloadable source.

nexus6 fucked around with this message at 15:08 on Jun 17, 2014

Adbot
ADBOT LOVES YOU

sim
Sep 24, 2003

I'm a big fan of Addy Osmani. He's written two very comprehensive books on JavaScript design patterns (including OOP and MVC) and Backbone, both of which are free online:
- http://addyosmani.com/resources/essentialjsdesignpatterns/book/
- http://addyosmani.github.io/backbone-fundamentals/

In short, models are for getting/setting your data and views are for presenting that data to the user. OOP and MVC are generally the same in JavaScript as they are in any language, but of course each library has specific differences. If you already understand OOP/MVC in PHP, I think it's safe to just start learning Backbone. There is no controller in Backbone, instead a view will contain most of that logic. The view then renders a templates that are more like the views from other MVC libraries.

Addy Osmani posted:

Models manage the data for an application. They are concerned with neither the user-interface nor presentation layers but instead represent unique forms of data that an application may require. When a model changes (e.g when it is updated), it will typically notify its observers (e.g views, a concept we will cover shortly) that a change has occurred so that they may react accordingly.

Addy Osmani posted:

Views are a visual representation of models that present a filtered view of their current state... JavaScript views are about building and maintaining a DOM element.

A view typically observes a model and is notified when the model changes, allowing the view to update itself accordingly. Design pattern literature commonly refers to views as "dumb" given that their knowledge of models and controllers in an application is limited.

Users are able to interact with views and this includes the ability to read and edit (i.e get or set the attribute values in) models. As the view is the presentation layer, we generally present the ability to edit and update in a user-friendly fashion.

EVIL Gibson
Mar 23, 2001

Internet of Things is just someone else's computer that people can't help attaching cameras and door locks to!
:vapes:
Switchblade Switcharoo
I tell you what, trying and constantly failing to install angular-phonecat or even angular-seed is making picking up this language REAL difficult to keep going with.

bower just refuses to run the git to get the prereqs. It's windows 7 x64 and I've tried x86 node js, x64, tried installing bower globally, dropping it back a couple versions, cleaning the cache, deleting folders, in AppData or the project itself and it will still die.

It does not help "support" seems to think that it's the developer who is responsible for figuring out how to make it all work even it calls for installing a loving virtual machine and installing debian.

Sorry for the bitching but I want to like this framework, but I'm at my limit.

code:
> angular-phonecat@0.0.0 postinstall S:\AngularWorkspace\angular-phonecat
> bower install

bower not-cached    git://github.com/angular/bower-angular.git#1.2.x
bower resolve       git://github.com/angular/bower-angular.git#1.2.x
bower not-cached    git://github.com/angular/bower-angular-mocks.git#~1.2.x
bower resolve       git://github.com/angular/bower-angular-mocks.git#~1.2.x
bower not-cached    git://github.com/jquery/jquery.git#1.10.2
bower resolve       git://github.com/jquery/jquery.git#1.10.2
bower not-cached    git://github.com/twbs/bootstrap.git#~3.1.1
bower resolve       git://github.com/twbs/bootstrap.git#~3.1.1
bower not-cached    git://github.com/angular/bower-angular-resource.git#~1.2.x
bower resolve       git://github.com/angular/bower-angular-resource.git#~1.2.x
bower not-cached    git://github.com/angular/bower-angular-route.git#~1.2.x
bower resolve       git://github.com/angular/bower-angular-route.git#~1.2.x
bower not-cached    git://github.com/angular/bower-angular-animate.git#~1.2.x
bower resolve       git://github.com/angular/bower-angular-animate.git#~1.2.x
bower ECMDERR       Failed to execute "git ls-remote --tags --heads git://github
.com/angular/bower-angular-mocks.git", exit code of #128

Additional error details:
fatal: write error: Invalid argument
|
npm ERR! angular-phonecat@0.0.0 postinstall: `bower install`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the angular-phonecat@0.0.0 postinstall script.
npm ERR! This is most likely a problem with the angular-phonecat package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR!     bower install
npm ERR! You can get their info via:
npm ERR!     npm owner ls angular-phonecat
npm ERR! There is likely additional logging output above.
npm ERR! System Windows_NT 6.1.7601
npm ERR! command "C:\\Program Files (x86)\\nodejs\\\\node.exe" "C:\\Program File
s (x86)\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "install"
npm ERR! cwd S:\AngularWorkspace\angular-phonecat
npm ERR! node -v v0.10.29
npm ERR! npm -v 1.4.14
npm ERR! code ELIFECYCLE
npm ERR!
npm ERR! Additional logging details can be found in:
npm ERR!     S:\AngularWorkspace\angular-phonecat\npm-debug.log
npm ERR! not ok code 0

S:\AngularWorkspace\angular-phonecat>
Alright, a loving solution finally

git config --global url."https://".insteadOf git://

Connect over https instead of git port.

EVIL Gibson fucked around with this message at 05:13 on Jun 18, 2014

Chenghiz
Feb 14, 2007

WHITE WHALE
HOLY GRAIL
I've about had it trying to get jQuery Mobile and React to play nice with each other. Can anyone suggest a UI framework that handles (nearly) as many mobile device use cases as jQuery Mobile that maybe isn't as opinionated about DOM manipulation and navigation? Looking for your standard web app UI elements like dialogs, touch friendly select menus, menu panels, etc.

nexus6
Sep 2, 2011

If only you could see what I've seen with your eyes
I just started working through the KnockoutJS tutorials and it makes so much sense to me. Is it logical to learn this as an intermediary step to using Backbone?

sim
Sep 24, 2003

nexus6: I think you can build entire apps using just Knockout, never learn Backbone, and you'll be fine. Or vice versa. Both libraries, along with every other JavaScript MV-whatever are all solving mostly the same problems. Knockout is more focused on the view layer and it adds two-way data-binding, which if you're coming from just jQuery, seems like a godsend. Backbone is more focused on RESTful interactions... but like I said, they can both solve the same problems: organizing complex code that allows users to interact with a lot of data.

Chengiz: what about Twitter Bootstrap or Zurb Foundation?

more like dICK
Feb 15, 2010

This is inevitable.

EVIR Gibson posted:

I tell you what, trying and constantly failing to install angular-phonecat or even angular-seed is making picking up this language REAL difficult to keep going with.

I "installed" angular by downloading the files and putting them in a 'static/js' directory in my project.

I feel like I don't understand Web 3.0 because apparently I was supposed to use Node.js and something called Bower to do this??

Skiant
Mar 10, 2013

more like dICK posted:

I was supposed to use Node.js and something called Bower to do this??

No you're not.

Bower sometimes makes thing easier but if you don't feel like Bower would be a huge improvement to your workflow, there's no reason for you to switch to it.
Get back on it later and see if you change your mind.

EVGA Longoria
Dec 25, 2005

Let's go exploring!

more like dICK posted:

I "installed" angular by downloading the files and putting them in a 'static/js' directory in my project.

I feel like I don't understand Web 3.0 because apparently I was supposed to use Node.js and something called Bower to do this??

Bower is just a package manager for website libraries.

It handles things like dependencies and keeping your libraries up to date for you, like any package manager. So if you have AngularJS + Bootstrap + Bootstrap-Angular + UI-Router all together, it can get a bit frustrating to manage all of that. That's where Bower is great.

Just using AngularJS? Drop that SOB in your JS folder. Or, even better, use one of the open CDNs for it (GoogleCDN is the official one @ https://developers.google.com/speed/libraries/devguide#angularjs ) -- no need to even download it in that case, and you might speed up your user's experience some too.

Kobayashi
Aug 13, 2004

by Nyc_Tattoo

EVGA Longoria posted:

Bower is just a package manager for website libraries.

It handles things like dependencies and keeping your libraries up to date for you, like any package manager. So if you have AngularJS + Bootstrap + Bootstrap-Angular + UI-Router all together, it can get a bit frustrating to manage all of that. That's where Bower is great.

Just using AngularJS? Drop that SOB in your JS folder. Or, even better, use one of the open CDNs for it (GoogleCDN is the official one @ https://developers.google.com/speed/libraries/devguide#angularjs ) -- no need to even download it in that case, and you might speed up your user's experience some too.

It's been a while since I've used Bower, but does it behave consistently? Last time I tried it, some packages would put their stuff in subdirectories, some wouldn't. Some would include non-JS assets, some wouldn't. Some would include version numbers, some wouldn't. In the end I'd still have to go through and figure out how the package named itself so I didn't see the value. Maybe I'm not using it properly or things have changed, though...

NovemberMike
Dec 28, 2008

Kobayashi posted:

It's been a while since I've used Bower, but does it behave consistently? Last time I tried it, some packages would put their stuff in subdirectories, some wouldn't. Some would include non-JS assets, some wouldn't. Some would include version numbers, some wouldn't. In the end I'd still have to go through and figure out how the package named itself so I didn't see the value. Maybe I'm not using it properly or things have changed, though...

IIRC it's literally a git wrapper. It just goes to the git repository for the project, finds the right tag, excludes a bunch of files that somebody specified and downloads the rest.

Count Thrashula
Jun 1, 2003

Death is nothing compared to vindication.
Buglord
Angular, Knockout, etc. are all just personal preference. All they do is connect your front-end with your back-end.

...you know, going by that description, I feel like somebody really needs to create TaintJS.

Lumpy
Apr 26, 2002

La! La! La! Laaaa!



College Slice

more like dICK posted:

I "installed" angular by downloading the files and putting them in a 'static/js' directory in my project.

I feel like I don't understand Web 3.0 because apparently I was supposed to use Node.js and something called Bower to do this??

Yeah, it's getting pretty stupid. I started dicking around with React and was looking at some routers for it, and all the README files are basically "npm install butt-router-lol" and that's it. Nobody even bothers with ".. Or just copy this one file into your js directory" any more.

My favorite is the React-Flux-TodoMVC example (http://facebook.github.io/react/docs/flux-todo-list.html) Paragraph 2 is basically "grab react-boilerplate, and then do all the npm install crap to get started." Paragraph 3 is "Oh, btw, the settings in the boilerplate package.json file all need to be changed to work with this tutorial. Look at our package.json file and figure it out."

Subjunctive
Sep 12, 2006

✨sparkle and shine✨

Lumpy posted:

My favorite is the React-Flux-TodoMVC example (http://facebook.github.io/react/docs/flux-todo-list.html) Paragraph 2 is basically "grab react-boilerplate, and then do all the npm install crap to get started." Paragraph 3 is "Oh, btw, the settings in the boilerplate package.json file all need to be changed to work with this tutorial. Look at our package.json file and figure it out."

I agree, that's pretty gross. I'll bring it up with the team.

EVGA Longoria
Dec 25, 2005

Let's go exploring!

NovemberMike posted:

IIRC it's literally a git wrapper. It just goes to the git repository for the project, finds the right tag, excludes a bunch of files that somebody specified and downloads the rest.

Yeah, this. It's basically all up to the package author how it's laid out. Half of them are just dist files, half are a full distribution including src and tests. It really is crap, but it's the kind of crap that comes about when working backwards with no central authority.

Kobayashi
Aug 13, 2004

by Nyc_Tattoo

EVGA Longoria posted:

Yeah, this. It's basically all up to the package author how it's laid out. Half of them are just dist files, half are a full distribution including src and tests. It really is crap, but it's the kind of crap that comes about when working backwards with no central authority.

So really, Bower should come with the caveat that it's only useful if you buy into the whole webdev toolchain: Setting up your package such that it can install all its dependencies, setting up your repository such that it ignores Bower's mess, use a task runner in such a way to build something that doesn't include all the extra cruft, etc.

nexus6
Sep 2, 2011

If only you could see what I've seen with your eyes
So glad it's not just me that gets pissed off that every github repo's 'usage' instructions is just "install with node". I still can't figure out what the heck node is for anyway.

Bastard
Jul 13, 2001

We are each responsible for our own destiny.
Granted, it's not a perfect system and has a long way to go, but it still beats searching for a certain file/lib, downloading it, find all the dependencies, download those, unzipping, moving all the files to the proper directory, etc. Also, on bower.io you can search through all the packages and see the github rating and when it was last updated. Nothing more frustrating then finding a library to use, only to discover that it hasn't been updated for over a year, or nobody uses it. But yeah, some sort of bower guideline to only include the main files, a minified file, dependencies and (good) readme would go a long way.

EVGA Longoria
Dec 25, 2005

Let's go exploring!

Bower is a step in the right direction. It's even a good first step.

It could really use a central authority dictating some guidelines (release in the package, source in package-devel for instance) and enforcing them.

Vulture Culture
Jul 14, 2003

I was never enjoying it. I only eat it for the nutrients.

EVGA Longoria posted:

Bower is a step in the right direction. It's even a good first step.

It could really use a central authority dictating some guidelines (release in the package, source in package-devel for instance) and enforcing them.
Everyone's got shell-shock from the Debian and Fedora packaging guidelines, so every new packaging system is the Wild West.

Plorkyeran
Mar 22, 2007

To Escape The Shackles Of The Old Forums, We Must Reject The Tribal Negativity He Endorsed
Debian packaging is easy. Step 1: write some code that people want to use. Step 2: let them deal with packaging it for Debian.

nexus6
Sep 2, 2011

If only you could see what I've seen with your eyes
Does anyone here make games with HTML5 canvas and JS? It's something I'd like to learn more about. Is there a separate thread for that?

Wheany
Mar 17, 2006

Spinyahahahahahahahahahahahaha!

Doctor Rope
I think I want to use React and Bootstrap together in a project. The reason is that React seems pretty nifty for building view components, and I like Bootstrap's layout, especially the responsive layout bits (from the little I've seen over a coworker's shoulder).

How dumb am I and how hopeless is this? Have I completely misunderstood what Bootstrap is for even?

Maluco Marinero
Jan 18, 2001

Damn that's a
fine elephant.

Wheany posted:

I think I want to use React and Bootstrap together in a project. The reason is that React seems pretty nifty for building view components, and I like Bootstrap's layout, especially the responsive layout bits (from the little I've seen over a coworker's shoulder).

How dumb am I and how hopeless is this? Have I completely misunderstood what Bootstrap is for even?

Eh. Its fine, you'll be doing an awful lot of component making and class names will be flying everywhere, but bootstrap/foundation whatever is fine if you're looking to get something off the ground.

The thing about React is you really need to be strict about determining what your components actually are. Try to avoid building the markup for a whole view in one render function, trying to conform to bootstraps markup needs. You'll just make things hard to maintain down the track.

Thermopyle
Jul 1, 2003

...the stupid are cocksure while the intelligent are full of doubt. —Bertrand Russell

Wheany posted:

I think I want to use React and Bootstrap together in a project. The reason is that React seems pretty nifty for building view components, and I like Bootstrap's layout, especially the responsive layout bits (from the little I've seen over a coworker's shoulder).

How dumb am I and how hopeless is this? Have I completely misunderstood what Bootstrap is for even?

It works just fine. I've been using Bootstrap with React for a couple months...

Spatulater bro!
Aug 19, 2003

Punch! Punch! Punch!

I make primarily non-database driven websites. Would learning Angular benefit me at all?

fuf
Sep 12, 2004

haha

caiman posted:

I make primarily non-database driven websites. Would learning Angular benefit me at all?

Maybe, it's pretty cool. I use it for dynamically loading content instead of the old mess of jquery ajax methods I used to use. You can use ngRoute to associate a url with a template file that'll load into the main view section of your page. So the url changes between views and the back button works, but you don't have to refresh the page.
(the only issue is that urls look like site.com/#/news instead of site.com/news)

You can also use angular to add "active" classes to nav links etc. Basically a lot of stuff I use to use jquery for I now do in a much cleaner / neater way with angular (except animations, because that poo poo confuses the hell out of me).

Tres Burritos
Sep 3, 2009

nexus6 posted:

Does anyone here make games with HTML5 canvas and JS? It's something I'd like to learn more about. Is there a separate thread for that?

Three.js is pretty great for 2D / 3D browser stuff. I made an asteroids clone with it a while back.

wwb
Aug 17, 2004

caiman posted:

I make primarily non-database driven websites. Would learning Angular benefit me at all?

Just the UI state management in a sane and rational manner works for me.

Then again I hate UI.

Thermopyle
Jul 1, 2003

...the stupid are cocksure while the intelligent are full of doubt. —Bertrand Russell

caiman posted:

I make primarily non-database driven websites. Would learning Angular benefit me at all?

Angular is cool, but be sure and look at Facebook's React as well if you're just looking for new things to learn to make building interactive websites easier. It clicks with me more than Angular.

--

I've been looking at Google's Polymer for an hour or so as I think their new Material Design is fantastic looking. Polymer is a pretty slick take on Web Components. I'm not sure how useful it will really be, though.

The big sticking point for me is that right now I don't see how to get it to work with React (which most of my current projects are built with), and it doesn't seem to offer enough to replace React.

excidium
Oct 24, 2004

Tambahawk Soars

fuf posted:

(the only issue is that urls look like site.com/#/news instead of site.com/news)

They don't have to! https://docs.angularjs.org/guide/$location and HTML5Mode settings.

Has anyone had a play with Polymer yet? Any thoughts so far for building any non-trivial apps?

excidium fucked around with this message at 02:24 on Jul 1, 2014

Coffee Mugshot
Jun 26, 2010

by Lowtax

Thermopyle posted:

Angular is cool, but be sure and look at Facebook's React as well if you're just looking for new things to learn to make building interactive websites easier. It clicks with me more than Angular.

--

I've been looking at Google's Polymer for an hour or so as I think their new Material Design is fantastic looking. Polymer is a pretty slick take on Web Components. I'm not sure how useful it will really be, though.

The big sticking point for me is that right now I don't see how to get it to work with React (which most of my current projects are built with), and it doesn't seem to offer enough to replace React.

It seems really nice if you want to play with all the Google stuff at the same time. I mean, using AngularDart alongside Polymer.dart has been pretty good for me. Granted, I couldn't imagine using the Dart Editor to actually edit anything.

Skiant
Mar 10, 2013
Aren't Polymer components basically like directives on steroids?
Our current project relies on Angular a lot and we should make more directives, but I'm wondering if Polymer components would not be a good thing.

Corla Plankun
May 8, 2007

improve the lives of everyone
Whats the name of the form element that contains selectable items and you can hold shift/ctrl to select more than one?

I have seen it used, for example, as a location selection for job search websites.

Chenghiz
Feb 14, 2007

WHITE WHALE
HOLY GRAIL

Corla Plankun posted:

Whats the name of the form element that contains selectable items and you can hold shift/ctrl to select more than one?

I have seen it used, for example, as a location selection for job search websites.

A select menu with "multiple" attribute. https://developer.mozilla.org/en-US/docs/Web/HTML/Element/select

Huragok
Sep 14, 2011

Skiant posted:

I'm wondering if Polymer components would not be a good thing.

The drawback of using Polymer is it doesn't play nicely with older browsers.

EVGA Longoria
Dec 25, 2005

Let's go exploring!

Huragok posted:

The drawback of using Polymer is it doesn't play nicely with older browsers.

In before "don't you mean bonus?"

Though, to be honest, I think we are at a point where legacy browsers can be ignored for modern web apps. The auto update processes in every browser are a lot better, I don't see much old school usage.

Vulture Culture
Jul 14, 2003

I was never enjoying it. I only eat it for the nutrients.

EVGA Longoria posted:

In before "don't you mean bonus?"

Though, to be honest, I think we are at a point where legacy browsers can be ignored for modern web apps. The auto update processes in every browser are a lot better, I don't see much old school usage.
As long as you're targeting desktop PCs only, and don't need to worry about compatibility of stuff like the built-in browser on old Android tablets and phones.

Skiant
Mar 10, 2013

EVGA Longoria posted:

In before "don't you mean bonus?"

Though, to be honest, I think we are at a point where legacy browsers can be ignored for modern web apps. The auto update processes in every browser are a lot better, I don't see much old school usage.

Sadly most of our customers don't give two poo poo about tech and probably use old Dell laptops they bought in the 1990s and never updated anything.

Adbot
ADBOT LOVES YOU

Sagacity
May 2, 2003
Hopefully my epitaph will be funnier than my custom title.

EVGA Longoria posted:

The auto update processes in every browser are a lot better, I don't see much old school usage.
Which line of business are you in, in which clients don't use IE8 anymore?

  • 1
  • 2
  • 3
  • 4
  • 5
  • Post
  • Reply