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
A MIRACLE
Sep 17, 2007

All right. It's Saturday night; I have no date, a two-liter bottle of Shasta and my all-Rush mix-tape... Let's rock.

Cool, subbing to this. Maybe it will bridge the gap between the web design/development thread and the Javascript questions thread!

Adbot
ADBOT LOVES YOU

A MIRACLE
Sep 17, 2007

All right. It's Saturday night; I have no date, a two-liter bottle of Shasta and my all-Rush mix-tape... Let's rock.

Wheany posted:

Well, I'm going to repost my question from the javascipt thread here:

How should I separate view data from server data?

If I have a view such as this (rendered as HTML):
HTML code:
<select multiple>
	<option value="1" selected>Butt</option>
	<option value="2" selected>Arse</option>
	<option value="3">Rump</option>
</select>

(The user has selected the first two values) Then some refresh script in the background updates the model, with
JavaScript code:
{
	1:"Butt",
	2:"Arse",
	3:"Rump",
	4:"Buns"
}
How do I preserve the user's selection when I re-render the select in response to "change:butts" event? The "selected" state is part of the view's state, it's not something that is synchronized back to the server, but it should not be lost just because an element changed.

If I remember correctly, in Backbone you have to call render manually right? When I was using it, I used it underscore.js templates. Anyways if you ARE calling render manually, maybe wrap that call in a closure, saving the selected index as a state in and of itself?

Wheany posted:

Yes, this is specific to Backbone, since that's the only framework I've used. Do other frameworks somehow automatically separate model data from view data with some kind of converters in between?

Knockout.js does this with ko.computed. I love knockout but it's probably easier to uhh, not change up your framework in the middle of a project.

A MIRACLE
Sep 17, 2007

All right. It's Saturday night; I have no date, a two-liter bottle of Shasta and my all-Rush mix-tape... Let's rock.

Wheany posted:

e: forgot to reply, but judging from the name "computed" sounds like exactly what I'm after in this case. Is knockout still being developed? A coworker was pretty excited about it a couple of years ago, but he said that it had been abandoned.

I'm not sure if it's still under active development. I used it over a year ago when my old company "revamped" our .NET stack to not be a huge pile of jQuery and nested ternary operaters (yes, really. Thanks 'lead' developer). Anyway Knockout as-is is fine, it doesn't really *need* anything, and will more than suit your needs if you have to clean up a huge mess. I used it with a bunch of underscore at the time, and I loved coding in it. But I kinda hate .NET/VS2012 and proprietary Microsoft stuff so at the time I was literally just using the server as a JSON / validation service, and did everything else with Javascript.

If you're absolutely married to the idea of having something definitely still under active development, look into other MVVM solutions. I don't know any off the top of my head though. Knockout owns though and you can use as little or as much of it as you need, you're won't be tied into a framework mindset like you are with backbone or angular.

A MIRACLE
Sep 17, 2007

All right. It's Saturday night; I have no date, a two-liter bottle of Shasta and my all-Rush mix-tape... Let's rock.

I'm willing to contribute to Meteor discussion and answer questions about it. But if you're just looking for a tl;dr there are plenty of good resources that we could probably just link to.

A MIRACLE
Sep 17, 2007

All right. It's Saturday night; I have no date, a two-liter bottle of Shasta and my all-Rush mix-tape... Let's rock.

rhag posted:

I just struggled with knockoutjs for a week. My data model was a bit complex, and it was a pain to get everything observable. After a while I went to the mapping plugin but it made everything worse. Then I used the viewmodel plugin, and while that was somewhat better, certain properties were not observable sometimes (and I was never able to figure out why).

Yesterday at 4pm I said, gently caress it and went to angular. At 7pm i went home. At 11 am this morning I was done with the page. Everything was bound properly, the html elements were all behaving as they should. It was a pure joy.
I went first with knockout since all I needed was data binding, and knockout does only that. Angular is quite a bit heavier, but man ... it is a joy to work with.

Knockout can be kinda weird at first until you get that your observable objects need their elements to also be observable recursively. Then it becomes easy.

A MIRACLE
Sep 17, 2007

All right. It's Saturday night; I have no date, a two-liter bottle of Shasta and my all-Rush mix-tape... Let's rock.

Yeah meteor only dumps the database in like the first 3 minutes of developing an app. then you turn off that feature and selectively publish data on demand.

A MIRACLE
Sep 17, 2007

All right. It's Saturday night; I have no date, a two-liter bottle of Shasta and my all-Rush mix-tape... Let's rock.

Okay can someone actually explain wtf an HTML directive is in Angular? Their docs say cryptic things like "Turn your markup into a DSL!" but I still don't understand, even after looking at the examples.

A MIRACLE
Sep 17, 2007

All right. It's Saturday night; I have no date, a two-liter bottle of Shasta and my all-Rush mix-tape... Let's rock.

Thanks for the writeups guys. I guess there was a disconnect where I didn't understand that it was basically "making your own tags"

A MIRACLE
Sep 17, 2007

All right. It's Saturday night; I have no date, a two-liter bottle of Shasta and my all-Rush mix-tape... Let's rock.

Pollyanna posted:

Hummm. I think I brought this up before in the web dev thread, but I was looking to recreate this in HTML/tables format, and figured that a JS framework would work best for it. Would Angular or Knockout be better for this?

Knockout isn't a framework, it's a library that binds the resulting html to the current state of your application. So if you want to write a program in javascript, and not worry about manually rendering stuff to the screen, use knockout.

A MIRACLE
Sep 17, 2007

All right. It's Saturday night; I have no date, a two-liter bottle of Shasta and my all-Rush mix-tape... Let's rock.

You can totally use knockout for this if you're intending to save the data somewhere (serverside? locally?). Represent the form data as json objects, then bind them to the view. After the user submits the form, all you need to do is post the json to your server and you can save the model that way. Will save you a lot of headaches from trying to `var selection = $("#myForm input[type=radio]").val();` all over the place.

Adbot
ADBOT LOVES YOU

A MIRACLE
Sep 17, 2007

All right. It's Saturday night; I have no date, a two-liter bottle of Shasta and my all-Rush mix-tape... Let's rock.

What project management tool are you using? I'm not a die hard agile fanboy but it can be helpful to organize your project into epics, features, sprints, bugfixes, release schedules etc. Look into kanban too if you like writing stuff on post it notes

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