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
Subjunctive
Sep 12, 2006

✨sparkle and shine✨

ManoliIsFat posted:

Then again, I don't know your exact requirements, so maybe you do need socket.io for the data to be pushed from the server instead of you polling it constantly.

socket.io can use longpoll or Flash or a bunch of transports, IIRC. It really was a wonderful "just works" experience across N browsers and whatnot when I last used it (~2 years ago).

Adbot
ADBOT LOVES YOU

an skeleton
Apr 23, 2012

scowls @ u
Any clue why an angular filter would throw too much recursion errors into the console/firebug?

Lumpy
Apr 26, 2002

La! La! La! Laaaa!



College Slice

an skeleton posted:

Any clue why an angular filter would throw too much recursion errors into the console/firebug?

I'm going to go with too much recursion on that one. :downsrim:

Post code.

N.Z.'s Champion
Jun 8, 2003

Yam Slacker
Is there a mobile framework/library with nice looking page transition effects? All the ones I've found look like crap, or don't support swiping, or are too slow on mobile

I made this demo of the kind of thing I'm looking for

http://static.holloway.co.nz/catalyst/swipe-pages/

kedo
Nov 27, 2007

N.Z.'s Champion posted:

Is there a mobile framework/library with nice looking page transition effects? All the ones I've found look like crap, or don't support swiping, or are too slow on mobile

I made this demo of the kind of thing I'm looking for

http://static.holloway.co.nz/catalyst/swipe-pages/

http://demos.jquerymobile.com/1.2.0/docs/pages/page-transitions.html Best I've been able to find.

jkyuusai
Jun 26, 2008

homegrown man milk
I attended a talk tonight on a framework called Durandal. It was given by the framework author himself. Towards the end of the presentation, he revealed that he's been hired onto the Angular team as an external consultant and is working to incorporate a lot of the ideas from his framework into Angular 2.0. He wouldn't give any sort of timeframe for a release, though.

A post announcing his hiring and his hopes for the partnership.

thehouseplant
May 2, 2007

jkyuusai posted:

I attended a talk tonight on a framework called Durandal. It was given by the framework author himself. Towards the end of the presentation, he revealed that he's been hired onto the Angular team as an external consultant and is working to incorporate a lot of the ideas from his framework into Angular 2.0. He wouldn't give any sort of timeframe for a release, though.

A post announcing his hiring and his hopes for the partnership.

He also mentioned it on the Angular blog a few weeks back:
http://blog.angularjs.org/2014/04/angular-and-durandal-converge.html

I'm really looking forward to seeing what the two become in Angular 2. I recently got a job doing front-end development and I went straight from "gently caress I dunno what any of this is" to Angular and haven't looked back.

Count Thrashula
Jun 1, 2003

Death is nothing compared to vindication.
Buglord
Speaking of Angular, I have a question.

I'm using ng-repeat to make an unordered list, and I know that basic "sort" and "filter" functions with that, but what I'm trying to do is custom sort is so that a certain match is at the top, a certain match is at the bottom, etc.

I know that it's possible to create a custom filter, but I'm not sure how to get started in re-ordering and returning a re-ordered list. If it were just an array or something I'd be fine with switching items around but for some reason connecting that with ng-repeat is stumping me.

Geno
Apr 26, 2004
STUPID
DICK
http://pastebin.com/AjhizPLf

https://docs.angularjs.org/tutorial/step_02

I'm messing around with some of the tutorial on AngularJS and a SaaS framework called ServiceNow. The objects GlideRecord, encodedQuery, query, next(), are all part of the ServiceNow framework.

Line 14-16 works fine but line 19-27 doesn't. Looking into the debugger, it looks like the objects being pushed in line 24 don't have a hashkey while line 16 does have one. The parameters for hi2.name gets passed fine. Any ideas on how to fix this?

e: nvm got it

Geno fucked around with this message at 01:01 on May 8, 2014

SuicideSnowman
Jul 26, 2003
I started playing around with Angular today and am obviously still very new to it and want to make sure I'm doing things the right way. I have basically a "master" page that has a navigation bar and a <ng-view> to dynamically load content. I'm doing so by simply calling a different page that I've configured in the router. It works, however I notice when viewing the html source for the page it's still just showing my master page and not any of the new page information. Is this normal or a problem in any way? If so, what's the correct way to handle a master page?

fletcher
Jun 27, 2003

ken park is my favorite movie

Cybernetic Crumb

SuicideSnowman posted:

I started playing around with Angular today and am obviously still very new to it and want to make sure I'm doing things the right way. I have basically a "master" page that has a navigation bar and a <ng-view> to dynamically load content. I'm doing so by simply calling a different page that I've configured in the router. It works, however I notice when viewing the html source for the page it's still just showing my master page and not any of the new page information. Is this normal or a problem in any way? If so, what's the correct way to handle a master page?

When you use the old school "View Page Source" it shows you the original HTML that was loaded for the page and doesn't reflect any changes made by JavaScript. You'll want to use the Developer Tools instead. Right click somewhere on your page and go to Inspect Element and it should open it up. (it's gonna blow your mind if you've never seen it before)

SuicideSnowman
Jul 26, 2003

fletcher posted:

When you use the old school "View Page Source" it shows you the original HTML that was loaded for the page and doesn't reflect any changes made by JavaScript. You'll want to use the Developer Tools instead. Right click somewhere on your page and go to Inspect Element and it should open it up. (it's gonna blow your mind if you've never seen it before)

That makes sense and I know about inspect element but I guess the whole concept of dynamically changing views is weird to me since I've been primarily using Asp.NET MVC and switching to different views is essentially reloading a new page. I've gotta say I'm really liking this so far. There's quite a learning curve though and don't want to start off by learning bad habits and inefficient practices. I'm building a fairly large application that involves a lot of client side manipulation and while Asp.NET was working for me (with a lot of help from jQuery and knockoutJS) it was starting to get a little unruly. I'm hoping the time it takes to learn Angular will allow me to create a better application in the end.

Kobayashi
Aug 13, 2004

by Nyc_Tattoo
Not really sure how to Google for this, but for modern Javascript, what kind of style recommendations are there for quotes vs. double quotes? Sometimes people seem to use double quotes extensively. Others use single quotes. I cut my teeth on C-like languages and Perl, so by habit I tend to only use double quotes for interpolation or escaped characters, but I wondered if modern JS has other conventions?

kitten emergency
Jan 13, 2008

get meow this wack-ass crystal prison
This is probably a dumb question (and may not be in the right thread), but I'm really new to trying to use express.js to create a little webapp. I've got a bunch of different routes set up in app.js like so -

code:
var activate = require('./routes/activate');
// etc

...

app.use('/activate', activate);
app.use('/post', post);
app.use('/login', login);
app.use('/users', users);
app.use('/home', home);
app.use('/', routes);
And my passport.js strategies are also defined in app.js. I can't seem to figure out a way to get the actual authentication to work, though. I've got a get and post method defined in login, but clicking the 'submit' button on my form isn't even submitting a POST request per the express logs, and if I use Postman to POST to /login it just returns the login page again (nor does it seem to make a call to my passport authentication strategy). I have a sneaking suspicion that nothing in my route files can access stuff in my app.js file, but that seems weird in my head (do I need to do the requires in each and every route, for instance? that would seem dumb).

I don't really know much about MVC either, which I think is hurting my understanding of this whole issue.

kedo
Nov 27, 2007

Kobayashi posted:

Not really sure how to Google for this, but for modern Javascript, what kind of style recommendations are there for quotes vs. double quotes? Sometimes people seem to use double quotes extensively. Others use single quotes. I cut my teeth on C-like languages and Perl, so by habit I tend to only use double quotes for interpolation or escaped characters, but I wondered if modern JS has other conventions?

Pretty sure it doesn't matter 99% of the time, although I believe double quotes are technically part of the JSON spec. Otherwise you can use either and it depends more on your own conventions than anything.

I like using single quotes in JS because I've always used double quotes in HTML. When I need to construct some markup in JS it means I don't have to constantly escape every single double quote.

Sedro
Dec 31, 2008

Kobayashi posted:

Not really sure how to Google for this, but for modern Javascript, what kind of style recommendations are there for quotes vs. double quotes? Sometimes people seem to use double quotes extensively. Others use single quotes. I cut my teeth on C-like languages and Perl, so by habit I tend to only use double quotes for interpolation or escaped characters, but I wondered if modern JS has other conventions?
Github is about 50/50 source

Kobayashi
Aug 13, 2004

by Nyc_Tattoo
Interesting, thanks. You ask people about tabs vs. spaces, or braces at the end of the line vs. braces on a new line and all hell breaks loose. With quotes, it sounds like it's basically personal preference.

Suspicious Dish
Sep 24, 2011

2020 is the year of linux on the desktop, bro
Fun Shoe

Kobayashi posted:

Not really sure how to Google for this, but for modern Javascript, what kind of style recommendations are there for quotes vs. double quotes? Sometimes people seem to use double quotes extensively. Others use single quotes. I cut my teeth on C-like languages and Perl, so by habit I tend to only use double quotes for interpolation or escaped characters, but I wondered if modern JS has other conventions?

I worked on a project long ago that used double quotes for user-visible text and single-quotes for internal strings, like identifiers, so that's what I do now. I acknowledge it's a weird personal rule and I don't really give a poo poo if people submit code to my projects that break the style.

Top Quark
Aug 2, 2010

"Going where no man has gone before."
If you use jshint (perhaps in a grunt task like me) then it will bitch and moan about any strings in double-quotes being wrong. Apparently that thing only likes single quotes for...everything.

abraham linksys
Sep 6, 2010

:darksouls:

Top Quark posted:

If you use jshint (perhaps in a grunt task like me) then it will bitch and moan about any strings in double-quotes being wrong. Apparently that thing only likes single quotes for...everything.

"quotmark": false, man http://www.jshint.com/docs/options/#quotmark

hedgecore
May 2, 2004
If you're working with JSON, use double quotes for the property names.
If you're working with strings of HTML via JS, use single quotes so you don't need to escape every double quote.

Otherwise, do whichever you prefer (or your team has agreed to use). Either way, just be consistent.

moctopus
Nov 28, 2005

So I've been using React thanks to this thread and I love love love love it.

It's the poo poo. I think the thing I like the most is the attitude it takes and tries to push on the developer of breaking things into smaller pieces. That's how I write software in general and what I push people I work with to doing.

I have the opportunity to give a presentation on React for a fun check-out-this-new-technology meeting at my office. After just leading the charge to implement SPA frameworks (Angular) into some of our more complex forms one of the things I'm going to be grilled on is "Angular Vs. React". I hate those types of question and I if I'm understanding React correctly React is mostly there for making a rad rear end view layer. It's not a huge fat assed routers and controllers and-and-and-and SPA.

I've been taking notes on the official React website and from Maluco Marinero's posts (thanks!) but I'm trying to come up with a list of things I can research that React does better than Angular. If anyone knows of some stuff I can read up on or more stories of React successes (I know there's a few in this thread) I'd really appreciate the guidance.

I think it makes view layer design easier. I like making cute lil components I can repeat. I know it's supposed to be super fast (hello Angular $watch), but I haven't done anything too crazy with React.

Also, React is the best. Even knowing I'm not 100% nailing best practices and am terrible as any person new to any technology I'm loving this. It's my best bud. My presentation has candy, glitter, and I used wacky scissors to cut stuff out. It's going to be the best like React.

Go learn React.

Maluco Marinero
Jan 18, 2001

Damn that's a
fine elephant.
Yep, been there, although we had some clear hair on fire problems that made the switch from Angular to React a no brainer. Performance primarily, we had a view that once the data set rose to a certain size we had pages taking 35 seconds to render in Angular + slow down for every action. My React performance test got that down to 3 seconds with more potential optimisations to be had, and from their I was pretty much told to go for it.

As for how they stack up for my mind:

Angular is good boilerplate, and very efficient on developer time for simple single page apps. It comes with plenty of batteries included so you can build something quick. However the boilerplate is almost non optional, which makes it heavy in structure. The way templates can be encoded with powerful logic can encourage a lot of bad reuse patterns that splits your codebase into lots of dependant chunks. That's not to say you can't make good reusable components in Angular, I just feel its poorly set up for it with global DI namespaces, splits between templates and code, and just a lot of tricks and gotchas to learn when you start to do things more complicated than simple bound forms.

Combined with some truly dreadful performance in complex scenarios, Angular doesn't end up saving developer time, and that gets worse the more that project deepens in complexity.

This is the key issue that I feel React has a better answer for, as a whole:

Its fast by default. Its easier to optimise from 3 second render times than 15 second render times, and if you're planning to go on mobile you need every default optimisation you can get. What works well on desktop with Angular can choke quickly with limited CPU and wasteful watch checks.

Its component driven with rigid definition of interfaces. The Property/State model actively protects the separation of concerns so you end up with components that can be reliably tested and composed into larger structures. Logic is also concentrated in JavaScript, rather than spread across HTML templates and JavaScript.

It has good allowance for testing. Recent versions have a suite of test utilities in Addons that make it dead simple to simulate events, detect sub components, etc. It also all goes back to being component driven, its easy to know all the dependencies and mock up effectively for testing.

There are less concepts to learn. React is much more concise in what it does and does not do. As a consequence the docs are well written, can be read completely in a single sitting if you wanted to, and are easy to browse. Meanwhile over in Angular land creating directives, the primary method of component reusability is such a heavy concept with lots of different stages and settings that renders the finer points hard to work with.

React dev has a slower output of functionality than Angular dev, but React components are longer lived and easier to develop cleanly, which over time results in a structure that allows you to make quite significant changes to functionality without the change having wide ranging implications. While that is possible with Angular, its arguably more difficult because of how easy you can end up with a tangled design without realising it. Angular's freedom ends up being a bit of a straight jacket.

So React might be slower to develop for in the short term, in the long term you'll have a stable and easy to predict velocity thanks to a more developer friendly framework. As for the batteries included bit, there are tonnes of libraries that do <x> better than angular. Some picks from me:

DateTime: momentjs
Translation: i18next
Keyboard: mousetrap
Promises: bluebird
Utilities: lodash

...but there's a ton out there so take your pick.

moctopus
Nov 28, 2005

Thanks a lot for typing that out, means a lot.

I also appreciate the inclusion of libraries at the end. I just so happen to be using lodash for the demo I'm using and I'm definitely going to check out those other ones you included.

Thanks again.

Urit
Oct 22, 2010

moctopus posted:

Thanks a lot for typing that out, means a lot.

I also appreciate the inclusion of libraries at the end. I just so happen to be using lodash for the demo I'm using and I'm definitely going to check out those other ones you included.

Thanks again.

Also, if you want routes then there's also the obviously-named react-router-component library. It ends up adding a couple of useless divs to the page but lets you define all kinds of fun stuff.

darkgray
Dec 20, 2005

My best pose facing the morning sun!
I've been wrestling with AngularJS the past few months, trying to make an ~interactive experience~ for listing a bunch of SQL data.

My wish is to make it possible to create hardlinking URLs, so I can get to page 3 or whatever if I type in my.url/#/page/3 and I assume the way to do this is to use routes. So I've been using routes! This seemingly has the additional benefit of letting users get to the right page when they hit the browser's Back button.

There are problems cropping up, though. For one, AngularJS will reload the route's controller every time you request a page, and this means the browser has to tear down the entire DOM of 5000 nodes or whatever, and rebuild it again with the new data. On a mobile device, this can take up to 5 seconds, which is possibly because I'm a retarded developer. I made a test-version where I just have the backing data itself replaced, without using routes, and it's about 10x faster to flip "pages" this way, but the trouble is, as I've mentioned, that it makes it harder for the user to just copy the current URL for future reference. My brilliant idea to solve this was to manually change the URL with $location.path() to match the displayed content, but this automatically gets AngularJS to reload the controller, which of course tears down the DOM and I'm back to square one.

Another irritating problem from a usability standpoint is that the teardown and rebuild of DOM means the browser can't maintain scroll positions when you hit the Back button, which makes it a chore to check out individual entries and going back to the list, etc.

Does anyone know if there's a Proper Way to handle pagination like this?

Maluco Marinero
Jan 18, 2001

Damn that's a
fine elephant.
Essentially you want to prevent angular's router from firing at all if you're currently within that controller. Not something I've done before but look at this:

http://uiadventures.wordpress.com/2013/09/06/routechange-angularjs/

On top of that you manually need to make use of push state to add support for the back button.

As you observed any use of the default router will scrub the DOM within ng-view, load a fresh template, load the controller and then compile the template. The only way to stop that happening is to keep the controller in charge if there's a matching change of route.

Phone posting but hopefully that's enough to make a start?

darkgray
Dec 20, 2005

My best pose facing the morning sun!

Maluco Marinero posted:

Phone posting but hopefully that's enough to make a start?

Thanks, I'll have a look at it and see if I can mangle it into something usable. Seems such a common dilemma, though.

Thermopyle
Jul 1, 2003

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

As we've had a decent amount of discussion around React lately, I'm debating tearing the React component I built around the Select2 jQuery widget out of the project I'm working on and putting it up on github so people can get an idea on how to use jQuery stuff with React. I've got to do some work on it to make it a bit less tailored to exactly what I'm doing is the only reason I haven't just done it.

Is anyone interested in seeing that?

karms
Jan 22, 2006

by Nyc_Tattoo
Yam Slacker
Yes.

jkyuusai
Jun 26, 2008

homegrown man milk

Subjunctive
Sep 12, 2006

✨sparkle and shine✨

Thermopyle posted:

Is anyone interested in seeing that?

The React team is.

fuf
Sep 12, 2004

haha

darkgray posted:

There are problems cropping up, though. For one, AngularJS will reload the route's controller every time you request a page, and this means the browser has to tear down the entire DOM of 5000 nodes or whatever, and rebuild it again with the new data.

You might also want to look into https://github.com/angular-ui/ui-router

It lets you nest views so you can update an inner view (and the url) without reloading the outer view. Here's a demo:

http://plnkr.co/edit/u18KQc?p=preview

Thermopyle
Jul 1, 2003

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

Subjunctive posted:

The React team is.

Ok, I don't know how good this is as I've only been fooling around with React for a month and JS for hardly any longer, but...

There's a demo here. Link to the Github on that page as well.

If anyone wants to work on it and help flesh it out I'm game for some pull requests or whatever.

fuf
Sep 12, 2004

haha
Where do people put their Angular (or whatever) template files?

They have to be accessible from the web right? Currently my project is laid out like this:

code:
- public/
-- css/
-- js/
-- img/
-- templates/
--- home.html
--- about.html
-- index.html
But it bothers me that in theory someone could access site.com/templates/home.html directly and get a broken, non-css version of a section of the site. Is there any alternative? Also does google crawl those files?

spacebard
Jan 1, 2007

Football~

fuf posted:

Where do people put their Angular (or whatever) template files?

They have to be accessible from the web right? Currently my project is laid out like this:

code:

- public/
-- css/
-- js/
-- img/
-- templates/
--- home.html
--- about.html
-- index.html

But it bothers me that in theory someone could access site.com/templates/home.html directly and get a broken, non-css version of a section of the site. Is there any alternative?

You could rewrite requests without a referrer (?) to templates/ back to the main page of the app.

Edit: hastily answered this on my phone. Not sure about it.

fuf posted:

Also does google crawl those files?

Google will attempt a request with #! replaced as a query parameter ?_escaped_fragment_=

So no it won't crawl them iirc. Though I may have a robots.txt with my partials/ directory in it.

The escaped fragment parameter would allow a public facing angular site to redirect google to statically cached pages via rewrite rules.

SuicideSnowman
Jul 26, 2003
So I've been using AngularJS for a little over a week now and I'm starting to get a better understanding of it. I'd just like to say that making "multi-page" forms are a lot easier than my previous methods using jQuery. I say multi-page in quotes because I don't really want separate forms for each page but just a separation of different divs to keep things organized.

Previously in jQuery I would have to create different divs with IDs of "page1", "page2", etc. Then I would .hide() all the pages I didn't currently need. After that a button would .hide() or .show() the different pages. It always seemed like a fairly hacky solution that would sometimes create content flashing and other anomalies.

In Angular I'm simply using the ng-switch directive and using $watch to watch a currentPage variable. Whenever the variable changes (based on a button click) it automatically updates the ng-switch directive with the necessary page. A much more elegant solution I must say.

While I'm sure there was a better way to handle it in jQuery I doubt it would have ever been this simple.

Asshole Masonanie
Oct 27, 2009

by vyelkin
FED friends, this is a super basic thing that I've gotten to work before but i can not for the life of me figure out why it's not working right now. It's a .NET environment for a web app and i'm just trying to do a simple class exception for IE but when I look at it in IE it does not seem to be working.

<!--[if !IE]><!-->
<body class="@(ViewData("bodyClass") & " " & IIf(Me.IsMobile(), "bt-mobile", ""))">
<!--<![endif]-->

<!--[if IE]>
<body class="@(ViewData("bodyClass") & " " & IIf(Me.IsMobile(), "bt-mobile", "" & "ie"))">
<![endif]-->

Is there something glaringly wrong with this? (besides that I am using .NET haha)

Molten Llama
Sep 20, 2006

HTML5 posted:

Is there something glaringly wrong with this? (besides that I am using .NET haha)

Which version(s) of IE? IE 10 and later don't honor conditional comments unless you're forcing them into quirks mode.

Adbot
ADBOT LOVES YOU

Asshole Masonanie
Oct 27, 2009

by vyelkin

Molten Llama posted:

Which version(s) of IE? IE 10 and later don't honor conditional comments unless you're forcing them into quirks mode.

Yeah this is the problem. I had no idea this was a thing so this makes sense now. I ended up fixing it the correct way without having to use an IE conditional. Flexbox rules when it works the way it's supposed to!

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