Could not convert JavaScript argument arg 0 [nsIDOMWindow.getComputedStyle]

I’m working on a small project at work using KnockoutJS (which is awesome by the way) and I ran into a problem which seems to only occur on Firefox. I’m using the beforeRemove method for my template that is supposed to use jQuery’s fadeOut method to fade the element out before removing it from the DOM. While this works on Chrome, and even Internet Explorer (!!!), I am greeted with the following error on Firefox (Firebug).

Could not convert JavaScript argument arg 0 [nsIDOMWindow.getComputedStyle]

A quick search on ol’ Google and I came to the conclusion that jQuery is attempting to style an element that no longer exists. This is weird, since the beforeRemove method was supposed to run before the element is removed from my observable array. So I tried replacing fadeOut with a simple hide method, and sure enough, it worked. So it means that it does run before the element is removed. But why doesn’t it work with fadeOut?

So I’m guessing the remove method is somehow called while the fadeOut method has yet to complete its run, resulting in jQuery to lose its DOM element to fade out.

My workaround is simple, run the remove method AFTER the fadeOut method is complete. In the below example, I have an Ajax call function called serviceProxy that contains a method called removeStory. Upon success, it will run the callback code which is supposed to fade out the deleted DOM element, and remove it from my observable array.

serviceProxy.removeStory(story.id(), function () {
	$('#post-' + story.id()).animate({ height: 0, opacity: 0 }, 'normal', function () {
		ctx.newsFeeds.remove(story);
	});
});

So I’ve decided to avoid using the beforeRemove method, at least until the KnockoutJS people come up with a solution and do this instead. It may not be the most elegant solution, but it works. You could also use jQuery’s then method for this, if you’re planning to do something else.

I’d like to hear from you guys about other solutions you guys came up with. Preferably something that would allow me to use the beforeRemove method.

Wassalam

A sneaky way of styling file input form fields

There may come a time when you need to style a file input form field on your page, but here’s the catch; there are currently no known way of styling the file input fields.

There are however, ways around this. Call it a hack, if you will. In this tutorial, I will demonstrate one of the methods you can use to “style” your file input fields. Note that this method does not work in Internet Explorer, and I’ve only tested it on the latest versions of Firefox (10.0.2), Chrome (17.0.963.56), Safari (5.1.2) and Opera (11.61).

Getting MediaElement to work with Media Gallery's lightbox (Colorbox)

OK, here’s a quick one for you. Say you’re setting up a media gallery in Drupal using the Media Gallery module. Say you want to include videos along with your images in said gallery. Say you want to use Media Gallery’s lightbox feature to allow your visitors to view your media in a nice pop-up JavaScript box. Say you want to allow your visitors to play your videos in said box using the MediaElement module.

Well, if you’re reading this, that means you’re facing the same problem as I did a few hours ago. The player just fails to load, and you’re left with something that looks like this;

Image of the mediaelement player failing to load

Share User Database And Avatars Across Multiple phpBB Boards

I got a request from one of my clients asking me to create a forum for his website. phpBB should work just fine, I thought. But here’s the catch. It needs to support three languages, namely Latvian, Russian and English. So I proposed a simple language switcher mod which simply switches the interface language to whichever language the user selects. The main forum page will look the same. But he didn’t want all the forums to be on the same page. He wanted the Latvian board to only contain Latvian forums, and the same for Russian and English. His explanation was that if we did what I was proposing we do, the Russian and English forum categories will be pushed to the bottom of the page, and if a Russian or an English-speaking person were to visit the board, he/she would not see the forum in their language, and would immediately leave the site.

So after hours of research, I came across this topic explaining how to share the user database across multiple phpBB installations. I’m no phpBB guru, so this was a simple enough solution for me. However I did come across a couple of issues while I was working on this, which I will explain in this tutorial.

Creating A Slideshow Using Views Slideshow In Drupal 7

Recently I’ve been trying to rebuild a website I previously built for a Malaysian company using Drupal. When I first made that website, I created a small content management system from scratch using PHP. It was part of a technical exercise for me, and it was only after that that I realised how faster and easier it would have been if I had built it using ready-made content management systems (CMS) like Drupal or Joomla.

For this particular website, I needed to recreate a slideshow which is displayed on the front page. I googled for tutorials and found that the easiest way to achieve this is through the use of the Views module, in particular the Slideshow sub-module. Unfortunately, the tutorials and how-tos I came across for setting up a simple slideshow were poorly written and very difficult to understand. After I finally got my slideshow up and running, I decided that it was best for me to write this small tutorial for others who want to do the same, and also for myself as a reference note for future use in case I ever need it.

Pagination


© 2017. All rights reserved.

Powered by Hydejack v7.5.0