Extending the Datatables plugin with FixedHeader

The Datatables jQuery plugin is a wonderful plugin and the FixedHeader add-on is the best of its kind that I’ve come across yet. It’s especially great that it can handle a frozen left column along with a fixed header. But how can you do this with multiple tables? Theoretically, you should be able to do it like this…

$(document).ready(function(){
    var settings = { 
        "bPaginate": false, 
        "bInfo": false, 
        "bFilter": false 
    };
    var tables=[];
    $("table").each(function(i){
        tables[i] = $(this).dataTable(settings);
        new FixedHeader(tables[i], { "left": true });
    });
});

Problem is the header of the left column does not stay frozen vertically or horizontally. The solution was to create another table with the left-most column of the header. Lock its position to the top left corner of the table with fixed positioning, but lock it to the offset position of 0 for top or left when you are scrolling past the fold in either of those directions.

Finished demo

Posted at 1am on 4/23/12 | Filed Under: JavaScript | Tagged:

qTip2 jQuery tooltip plugin with jQueryUI selectmenu

I’ve used many of these tooltip plugins, but qTip2 has got to be the best one. The documentation is great, it’s highly customizable, and so far I haven’t had positioning problems as I do with most tooltip plugins. Recently, I paired it with a jQueryUI selectmenu.

Finished demo

Posted at 12am on 4/23/12 | Filed Under: JavaScript | Tagged: , ,

Heel-Toe Bass Drum Technique

This two-part video is the best explanation of the heel-toe technique I’ve found on the web. Props to Jared Falk. It was one of those things I thought I’d never figure out, but sure enough, practice does make perfect.


Posted at 3am on 1/29/12 | Filed Under: Drums & Percussion | Tagged:

Saving and Reading Many-to-Many Relationships in Yii

Finally after a half year of trial and error, I was able to resolve the problem of saving and reading many-to-many relationships in Yii with help from the following two links:
http://www.tipstank.com/2010/07/19/retrieving-selected-checkbox-items-in-yii/ (for the reading)
http://www.yiiframework.com/forum/index.php?/topic/16936-many-to-many/ (for the saving)

In my project, a Place can have many Types and a Type can have many Places. Creation, reading, and updating is done by way of multi-selectable checkboxes.

In Place controller in both the actionCreate and actionUpdate methods:

if(isset($_POST['Place']))
{
    $model->attributes=$_POST['Place'];
    $model->types = $model->typeIds;
    if($model->save())
        $this->redirect(array('view','id'=>$model->id));
}
$this->render('create',array(
    'model'=>$model,
));

In the Place model (active record):

public $typeIds = array();
 
...
public function relations()
{
    return array(
        'types' => array(self::MANY_MANY, 'Type', 'place_type(place_id, type_id)','index'=>'id'),
    );
}
 
// You will need to download the CAdvancedArBehavior extension
public function behaviors() 
{
    return array('CAdvancedArBehavior' => array(
        'class' => 'application.extensions.CAdvancedArBehavior'
    ));
}
 
public function afterFind()
{
    if (!empty($this->types))
    {
        foreach ($this->types as $n => $type)
            $this->typeIds[] = $type->id;
    }
    parent::afterFind();
}

In Place view _form template:

<div class="row">
<?php echo $form->labelEx($model,'type'); ?>
<?php echo $form->checkBoxList($model,'typeIds', 
    CHtml::listData(Type::model()->findAll(), 'id', 'name')); ?>
<?php echo $form->error($model, 'type'); ?>
</div>
Posted at 8pm on 1/9/12 | Filed Under: Webdev | Tagged:

Giovanni Hidalgo on the timbales


I love the energy of the first impromptu performance.

Posted at 11pm on 11/3/11 | Filed Under: Drums & Percussion | Tagged: ,

Tito Puente: The High Priest of Salsa Music


The video that caused me to order a set of timbales.

Posted at 5am on 10/21/11 | Filed Under: Drums & Percussion | Tagged: ,

“Music is expression of harmony in sound. Love is the expression of harmony in life.”

Posted at 8am on 9/30/11 | Filed Under: Quotes |

More from Mr. Ducroz


I love this guys’s work.

Posted at 9pm on 7/20/11 | Filed Under: Motion Graphics |

Stop motion + CG printed on paper = totally awesome.

In my opinion, these motion graphic pieces are the most inspiring I’ve seen since Michel Levy’s Giant Steps video. By Benjamin Ducroz.

Posted at 4am on 7/9/11 | Filed Under: Motion Graphics |

LABjs

It was eating away at me everyday at work that we didn’t have a system in place to manage dependencies. Besides efficiently handling dependencies, it is something we need to learn about and what better way to do that other than integrating such a system in our own product? So we tried RequireJS and realized that it was not well-suited for our current codebase. In order to really take advantage of RequireJS, it is recommended that you use their module defining method to build blocks of protected code. It might have been great had we started building our app that way, but I felt it would be too huge an undertaking to overhaul our code to that extent with no guarantee that it will be the best solution. So we opted for LABjs, another open source script loading managing system. I’ll write an update at the end of this sprint when it will have been fully integrated into our site.

Posted at 11am on 6/25/11 | Filed Under: JavaScript | Tagged: ,

“The question isn’t who is going to let me; it’s who is going to stop me.”

— Ayn Rand

Posted at 2am on 6/17/11 | Filed Under: Quotes |