Archive for the 'Geek speak' Category

Executing embedded JavaScript after Ajax-call

A nasty problem jumped up and bit me in the ass a few days ago at work. I was making a widget of a piece of code formerly part of the web page now hosting the widget. The widget code consisted of some HTML and a couple of embedded JavaScript tags. The widget needed to be loaded into a div the hosting web page with an Ajax-call, after which the embedded JavaScript needed to be executed. Something like this (I’m using YUI3 here):

Y.io("/foo/bar/some_widget", {
  method: 'GET',
  on: {
    complete: function(id, respdata) {
      thediv.innerHTML = respdata.responseText;
      initWidget(); // this function is embedded in the responseText
                    // and doesn't get evaluated. I.e. it doesn't exist.
    },
    failure: function(id, respdata) {
      alert('Feed failed to load!');
    }
  }
});

If a search engine sent you here, you probably know that this doesn’t work. JavaScript embedded in a piece of HTML code loaded with Ajax and injected in a web page doesn’t get evaluated. If you’re wondering why, you’re in the wrong place. If you want to know how to make it execute, read on.

Continue reading ‘Executing embedded JavaScript after Ajax-call’

Connect Leopard to the Internet using a Nokia phone

Despite numerous howtos and instructions on connecting a Mac to the Internet through a Nokia phone, none of them has corresponded 100% to my reality and thus I’ve always failed. However, through a bit of trial and error, I managed to find out how to connect my MacBook running Leopard to the Internet using my Nokia E66.

Continue reading ‘Connect Leopard to the Internet using a Nokia phone’

IE6 users: upgrade your browser — now!

Up until now, I haven’t really cared what browser people are using. I haven’t designed any commercial web sites for a long time and in the research projects I worked on at HIIT, we always had a target device or target browser, disregarding the poor bastards that didn’t use the right equipment.

Things are different now. I’m developing a real web application for real people with real browsers (or not), which means that I more than ever need to take into consideration what gear people are using our application with. This would be fairly simple if it weren’t for all web designers nemesis: Internet Explorer 6. Let us together once and for all put this freak to rest. Please.

Continue reading ‘IE6 users: upgrade your browser — now!’

Rewriting the WPG2 URL

I’m sick and tired of the new WPG2 plugin for Wordpress forcing me to use the embedded gallery page. Sure, nowadays you can configure it to look identical to the actual gallery, but that doesn’t satisfy me. Since my gallery is on another virtual domain (gallery.fredrikbostrom.net as opposed to blog.fredrikbostrom.net) I want the images in my Wordpress sidebar to link to a page where the URL tells me that I’ve moved away from the blog and am now viewing the gallery. WPG2 version 3.x doesn’t do this, so I decided to fix it myself (yet again a case of “if you want something done, do it yourself).

Continue reading ‘Rewriting the WPG2 URL’

Goodbye Amarok – welcome mpd

I just discovered the perfect solution to one of my biggest problems in recent memory, i.e. controlling playback of my music playing on my Home Entertainment Computer. It’s called mpd and I love it. I love it I love it I love it I love it. Why didn’t anyone tell me about this earlier? It lets me remote control music playback on my entertainment machine from virtually any device in my flat. Well, I don’t think there’s an mpd client for coffee brewers yet, but still.

Continue reading ‘Goodbye Amarok – welcome mpd’