Weird bug in AngularJS $http?

Modified 2013-08-28; Categorized in

At work we’ve been working with AngularJS for a few months, and we are very pleased with its flexibility and solutions to many familiar problems when working with large amount of JavaScript code. There have been problems and bugs, but none we couldn’t solve in due time.

But my latest task have left me somewhat puzzled, and I write this post in the hope that somebody out there know what it was about, and also because I just ain’t able to summarize it into a proper question on a forum or what-have-you. So here goes.

The task required me to work with a 3rd-party service through an iframe. The service in question is Checkbox Survey, which we use to, well, make surveys. We embed a given survey within the iframe, and run some code that looks for a specific ID within the embedded page. The gist below shows part of the directive that handles how we “look” for this.

Upon completion (or pausing) an event is emitted. This event is fetched by a parent controller, and the gist below shows how it’s handled.

Ideally, line 2 and 3 wouldn’t be needed. Ideally, $scope.result.$complete would’ve been called (it’s a $http-object), and success would be triggered upon a (hopefully) successful result. But this doesn’t happen. It seems that the browser need the user to interact with the page before it will send the request. To enable this, and to guide the user so she doesn’t navigate away from the page until the request is sent, I’ve included a link that’s shown when showButton is truthy. The link doesn’t actually do anything but link to “#”, as shown in the gist below.

I also realized that scope.$digest was necessary to get the button shown. Another hack I’m puzzled by. This is far from an elegant solution, and I hope that maybe someone out there will stumble upon this post and give me some advice about what is amiss. Or I’ll find it out myself, and update this post later.

Vitamins

Categorized in

About a year ago, S.B.LattinDesign posted a really cool infographic named More Than Supplemental.

I found it about a month ago, and I really liked it! In fact, I liked it so much I wanted to make an interactive version of it, and Supplemental Interactive is the result. It isn’t quite finished yet (e.g. I want to include icons instead of abbreviations), but I believe my vision is communicated. It is available in multiple screen sizes (using RWD), but in my opinion is best utilized on wide screens.

I used a set of tools to make it: D3.js to visualize the data, jQuery to ease DOM-handling, Underscore for utility functions, Sass as CSS-preprocessor, Compass for extra mixins, Bootstrap for some good markup-handling, and Buster.JS to test the JavaScript. All of the code is available at GitHub.

Hope you like it! ^_^

Projects 2013

Categorized in

I like to keep myself occupied, previously exemplified by my involvement in several student organizations while I studied (one in which I still partake with my time and effort, albeit in diminishing manner). Since I completed my master thesis this fall, I’ve tried to limit my involvement, and concentrate on work and getting on route with my life as a professional. I believe myself to be on the right path now, and hope to increase my involvement once again, as this post will describe.

Continue reading

Installing Buster.JS

Categorized in

As mentioned in my previous post, I’ve been wanting to use Buster.JS as test framework for my implementation of the master thesis. After installing node, I was ready to install buster. Or so I thought. With npm  (package manager for node) I tried “npm install -g buster”, which gave me an error (full output). It seemed that the module glob wasn’t available in the version buster needed.

Continue reading

“/usr/bin/ld: cannot find -lz” when building node.js

Categorized in

As part of the thesis I’ve been looking around for test framework for JavaScript. I’ve found Buster.JS, and its support of mocking, stubbing and asynchronous tests appealed to me. It required Node.JS to work, so I began the task of installing it. I started getting errors, and as I’m not that experienced with the whole compiling-process (I’ve experience from courses where we programmed with C and assembly, but ain’t really fond of it). It took me some time debugging the problem, but the line “/usr/bin/ld: cannot find -lz” stood out after some iterations.

Continue reading