New Bakery Article - Easy Ajax Pagination with JQuery
Tuesday, May 6th, 2008My love affair with JQuery continues with my new article about using JQuery for easy Ajax pagination at the CakePHP Bakery. Go ahead and check it out, it’s pretty slick.
My love affair with JQuery continues with my new article about using JQuery for easy Ajax pagination at the CakePHP Bakery. Go ahead and check it out, it’s pretty slick.
Ahh, the Commons Cam. What would we do without our frivolous little mental-health-preserving project? If you’ve noticed a lack of posting here at the Red Frog Blog, it’s because we’ve been busy. Really busy. Brains-on-wall busy. And with all manner of projects, print, web, application development, you name it, we’ve done it in the past month.
So with a new, amazing, beautiful, slick version of WebTree coming out sometime next week, I took a short break from application development today to play with our Commons Cam site, and added a cool new feature.
It’s called a visual time stamp. Any time someone makes a comment on the site, the system now automatically saves a copy of the webcam’s view. That way you can see what the hell someone was commenting about, or you can comment when you see a particularly pretty view, or a particularly strange one.
So go ahead and visit the Commons Cam and let us know what you see. And perhaps share it with some friends?
Enjoy!
I just noticed that in CakePHP 1.2 beta (6311), if you’re using the paginator helper, and attempting to sort data with the sort() function, AND you’re passing URL information, you need to specify the model explicitly in order to have the function take care of flipping the asc/desc sort direction.
Maybe this will make it more clear:
If I was just doing this:
< ?php
echo $paginator->sort(’Name’,'name’,array(’url’=>Router::getParam(’pass’)));
?>
The generated sort link would always have the sort direction set to ‘asc’. Is this a bug? I’m not sure, probably. (Notice how I feed the Router’s pass params into the URL to preserve the current passed arguments to the controller function). To make this work, just specify the model explicitly:
< ?php
echo $paginator->sort(’Name’,'name’,array(’url’=>Router::getParam(’pass’),’model’=>’Image’));
?>
And now the sort direction in the generated URL will flip between ‘asc’ and ‘desc’ depending on the current listing.
Also, if you want to show the user which way we’re currently sorting, you can including the current sort direction as a class on the link:
< ?php
echo $paginator->sort(’Name’,'name’,array(’url’=>Router::getParam(’pass’),’model’=>’Image’,'class’=>$paginator->sortDir()));
?>
This will add the classes ‘asc’ or ‘desc’ to the link, and you can do some easy CSS styling to show directionality:
a.asc {
padding-right:20px;
background-image: url(../img/up-arrow.gif) top right no-repeat;
}
a.desc {
padding-right:20px;
background-image: url(../img/down-arrow.gif) top right no-repeat;
}
There’s lots more on pagination, make sure to check out the two Bakery articles: Basic Pagination Overview, and Advanced Pagination, both by Rob Conner.
I just ran into this today while I was updating the TinyMCE editor in WebTree. I noticed that any drop-down menus created from the “Select Style” or “Select Formatting” options would create a 1-pixel wide “menu” instead of an actual menu in Firefox. Awesome! I looked at the HTML it was generating, and it seemed to include an inline style setting the menu DIV to be 0 pixels wide with a 1px border.
I’m not sure why it was doing this.
In Safari, it would generate the menu correctly the first time you clicked on it. Subsequent clicks to show the drop-down menu resulted in a increasingly narrow menu-width, until about the 5th click, at which point we’d hit the 0 pixel limit.
After much wasted time looking through the source code and finding nothing, I found a hint to an alternate solution in the API to the function that writes out the menu. There’s a new setting, called use_native_selects; that apparently was just added in this version. It looks like it is set to true by default, which was causing it to attempt some unnecessary crap writing out a JS menu instead of the browser-specific drop-down menu.
I added this line to my tinyMCE.init({}) settings:
use_native_selects: true,
And the problem was solved. Not as uniform an experience, but that’s ok. It’s functional, and that’s all I really care about. Not sure if there’s any other reports about this bug, but hopefully this will save you some time. Pretty annoying new feature, though, isn’t it?