June 2011
1 post
SC2.0 & TemplateViews, some short thoughts
It’s been a really long time since I’ve posted any tips, sorry. Mostly because I moved onto other projects & wasn’t using SproutCore for awhile. I started using it again a month or two ago, so onto some tips.. but first I just wanted to comment on the SC 2.0 bit… I see a lot of people asking the same questions over and over “What do I use” and worse, people...
Quick "dynamic" layout!
You can adjust a views position at any time by simply calling this.set(‘layout’,{top: x, bottom: y, height: z, width: v} ); instant view movement!
I use this fairly often when I get data back from the server, or want to place a view in a specific position based on user interaction (like a click, or a mouse in/hover action)
May 2010
10 posts
A simple progress indicator
I was looking for a way to do a progress indicator, and did find this helpful tutorial, http://wiki.sproutcore.com/Tutorials+-+Loading+Indicator but its based off records returning their state, which isn’t very helpful if you aren’t interacting with records yet.
There is also an easy way to do it in jQuery, found here which uses .ajaxStart & .ajaxStop to add/remove a DIV.
Lastly,...
Debugging Tips! Part 1
I have had a heck of a time getting up to speed with regards to debugging my sproutcore app. Hopefully you are already aware of Firebug & Safari Web Inspector . Sometimes I’m not able to step through in the debugger, for various reasons.
(Quick hint! You can’t leave “debugger;” statements in and do an sc-build! It will fail.
Now, once you are in the console there...
You ended up using context.begin... but its...
You searched and searched for how to do something, and the only thing you could find were some tutorials about going into the context & pushing values. Fantastic.
You saw that you can
context = context.begin(‘table’).addClass(‘myCSSClass’);
And hey that was pretty cool, you know some CSS and how to use a class. But you also need to add an id and scope. Hmm....
Getting data into child-child views without the...
Hopefully you’ve seen the composite view tutorial,
http://www.itsgotwhatplantscrave.com/2009/07/29/composite-views/
It’s an excellent example of extending a view to save yourself from duplicating code. To give an example of how I used it, I had a particular “table view” that consisted of a lot of heavy styling. Which involved of course divs and classNames.
In the end,...
hawleyw asked: Is there a way to change the default copyright notice that sc-gen puts in the generated .js files?
Integrating with other frameworks (flot, django,...
Since it was relevant to me, I thought I’d post a few links for getting charting & data backends integrated with Flot. There are a couple easy hits on google. I’ve also heard someone! is working on native sproutcore charting. He is a very busy someone however, but I’m sure we’ll see something in the coming months.
Flot
...
Where does it all come from?
I don’t want people to get the wrong impression; I’m not this smart. All of this knowledge is merely what I condense down from the very smart and very helpful people in #sproutcore on freenode.net. Its also not always verbatim what they say, its how I see it through my eyes, as I’ve been learning sproutcore. And of course, its perfectly liable to be “well, thats not...
Using your fixtures in sc-build
Alright, so you read through the datastore tutorial, it told you all about fixtures, and that it was a stop gap for hooking up to a real data source. It even gave you a neat shortcut to fall back on fixtures.
// in main.js:
MyApp.main = function() {
// switch to fixtures if #fixtures in URL
if (window.location.hash.toString().match(‘fixtures’)) {
...
The ' vs the "
It ends up being a javascript thing, even Javascript: The Good Parts, didn’t mention it (That I recall; This may be merely due to my first adventures into Javascript from Obj-C that it kept tripping me up! )
And the answer is, you can actually use either ” or ’ but you should stick with one convention throughout your code. Yeah, its confusing to read through the sproutcore...
SC-Gen naming conventions (why isn't it doing as I...
When I first started using sc-gen, little things kept tripping me up.
If you type “sc-gen model MyApp.SomeValue”
You’d get a file called “some_value.js” (note a _ is added, and your case is missing). Worse, when you open the file, you’d be back in “some_value.js” using MyApp.SomeValue! The good news is, according to my understanding, this is...