Archive for September, 2007

h1

Problems with AJAX and IE

September 18, 2007

I had set up a page with a nice drag and drop interface and it worked lovely in Firefox and Opera. But when I went to try it in IE, it would work once and then not again.

What was happening was that after the drop, the page would refresh and the drop area would be created again inside of the old one. Firefox ignored it but IE decided that it wanted things to be right for a change.
So adding this little bit of code between script tags:

if (document.all) { Droppables.drops = [] }

before the creation of the drop area meant that it would clear out the area for a new one to be created.

This page has the full explanation:
AJAX problem with drag and drop for Internet Explorer using Scriptaculous

h1

This page is handy

September 17, 2007

Drag ‘n drop tutorial with the CakePHP 1.2 Ajax helper, Prototype framework and Scriptaculous library
Drag and Drop explained really nicely. The only thing that I have changed from his method is to put a letter in front of the id name for each option that will be dragged. This I then strip in the controller and play as usual. I made this change because my pages weren’t validating any more.

h1

A nice way to check if there are orphaned entries

September 5, 2007

In a database table that is linked to another, sometimes an entry gets deleted and the children of that entry don’t get deleted along with it. Use this little bit of SQL to check for these entries:
SELECT one.id
FROM one
WHERE one.other_id NOT IN (
SELECT other.id
FROM other);

This can then be modified to delete those entries by changing the SELECT one.id to DELETE, like this:
DELETE
FROM one
WHERE one.other_id NOT IN (
SELECT other.id
FROM other);

h1

If you have problems with beforeFilter

September 3, 2007

I was having some problems trying to use the beforeFilter function in my controllers because I was using it in app_controller.php as well. In app_controller.php I was playing with the session variables and this was breaking when I went to use the beforeFilter function in any of my controllers. The workaround is very simple and came from the mailing list.
In you controller version of the beforeFilter function, add in the following line:
parent::beforeFilter();
before you do anything in the function. This explicitly calls the beforeFilter function in app_controller.php and runs it first.

Thanks to Jon Bennet for that little nugget

Follow

Get every new post delivered to your Inbox.