Filed Under (General) by Wenbert on 22-05-2008
This has been out like crazy in the PHP Community. All my RSS Feeds for PHP have like 2 or 3 links related to the ZF and Dojo partnership so you have probably heard of this post.
I have known about Dojo a few years back before MVC frameworks were going mainstream. I think Dojo was the obvious choice for the Zend Framework Team. Dojo is very mature and it has lots of components. I have no idea how bloated it is though. Personally, I would have selected jQuery because I use it and second, I love it’s small size and functionality. It is about time is tag along with the others and start using Dojo too 
Filed Under (General) by Wenbert on 09-04-2008

Here’s an experiment in keepings things small and confined to one Javascript file. There are no external image files or anything, everything is rendered with Javascript using either canvas elements or old fashioned div-making tactics (for IE). The sprites are stored in custom encoded strings in a format that only allows 4 colors for each sprite but in turn only takes up around 40-60 bytes per sprite.
We also have MIDI music embedded as base64-encoded data: URI’s. No music for IE, though, and it seems all the other browsers each have different, minor problems with it, but it sort of works.
It is by no means a complete clone or anything, it’s not even an entire level and several key things are missing, such as mushrooms, Koopas and stuff. It was merely done as a sort of proof-of-concept and to see how small it could get.
Performance varies somewhat between the different browsers, but Firefox, Opera, Safari and IE are all playable. The latest WebKit nightly seems to give Safari a speed boost.
Be sure to click the mouse on the game if Mario won’t move. When you die, you have to reload the page to start over. And yes, you can move left. Sorry.
I tried to download the Javascript file and simulate it in my local machine to see if it really works, and it does! Amazing!
Filed Under (General) by Wenbert on 28-03-2008
You can do this in jQuery:
$("textarea[@name=my_field_name]").val()
$("input[@name=my_field_name]").val()
Filed Under (General) by Wenbert on 24-03-2008
This is useful if you want to “delete” or “update” multiple rows in a table at the same time. This works like the “Check All Email” in YahooMail.
$ (document ). ready(function() {
//check all checkboxes
$ ("#check_all_boxes"). click(function() {
$ (".mycheckbox"). each(function(i ){
$ (this). attr("checked", "checked");
});
});
//uncheck all checkboxes
$("#uncheck_all_boxes").click(function() {
$(".mycheckbox").each(function(i){
$(this).removeAttr("checked");
});
});
//reset the search form
$("#reset_button").click(function() {
$("#search_form input").each(function(i) {
//alert($(this).html());
});
});
});
And the HTML Code is:
< input class="mycheckbox" name="a" value="1" type="checkbox" />Number 1
< input class="mycheckbox" name="b" value="1" type="checkbox" />Number 2
< input class="mycheckbox" name="c" value="1" type="checkbox" />Number 3
< a href="#" id="#check_all_boxes">Check All< / a>
< a href="#" id="#uncheck_all_boxes">Uncheck All< / a>
Filed Under (General) by Wenbert on 19-02-2008
The scenario: Every time you click on a row, the row highlights. When you click on the highlighted row - remove the highlight.
The jQuery / Javascript code:
//highligths the clicked row
function highlightrow(obj) {
if ($(obj).attr("style")==‘background-color: rgb(255, 255, 187);’ || $(obj).attr("style")==‘BACKGROUND-COLOR: #ffffbb’) {
$(obj).removeAttr("style");
} else {
$(obj).attr("style","background-color: #FFFFBB;");
}
}
And for the HTML Code:
..rest of the HTML tags here…
< tr onclick="highlightrow(this);" >
..rest of the HTML tags here…
Filed Under (General) by Wenbert on 04-02-2008
Alright, here is a quick example of how to use jQuery to select all of the items in a multiple-option select box.
//Javascript part assuming that you have already included jquery.js in your header
$(document).ready(function() {
$("#select_all_col_managers").click(function() {
$("#col_manager_list").each(function(){
$("#col_manager_list option").attr("selected","selected"); });
}) ;
$("#unselect_all_col_managers").click(function() {
$("#col_manager_list").each(function(){
$("#col_manager_list option").removeAttr("selected"); });
}) ;
});
and now for the HTML part…
Filter by Collection Manager:
< select class="select_multiple" id="col_manager_list" multiple="multiple" name="RTCLMG[]">
< option>Must Select One
< option> value="< ?=$value['col_manager']?>">< ?=$value['col_manager']?> < / select>
< a href="#" id="select_all_col_managers">Select All< / a>
< a href=”#” id=”unselect_all_col_managers”>Unselect All< / a>
Please note that I am using Code Igniter with this.
Filed Under (General) by Wenbert on 23-11-2007
In some cases, you are required to do something (EG: show/hide divs) when a checkbox is clicked. Here is an example using jQuery.
First your checkbox will look like this:
...html code here...
< input name="myCheckBox" id="myCheckBox" value="yes" type="checkbox" /> This is a sample checkbox.
Then somewhere in your HTML head, your Javascript code will look like this:
… other code here…
$(‘#myCheckBox’).click(function(){
if (this.checked) { //this.checked is NOT from jquery
alert(‘Do any action here.’);
} else {
alert(‘Undo the action here.’);
}
});
…other code here…
NOTE: Do not forget to download and then include the required jQuery files in your HTML File.
Filed Under (General) by Wenbert on 22-11-2007
I found this:
jRails is a drop-in jQuery replacement for Prototype/script.aculo.us on Rails. Using jRails, you can get all of the same default Rails helpers for javascript functionality using the lighter jQuery library.
jRails provides drop-in functionality for these existing Rails methods.
o Prototype
o form_remote_for
o form_remote_tag
o link_to_remote
o observe_field
o observe_form
o periodically_call_remote
o remote_form_for
o submit_to_remote
o Scriptaculous
o draggable_element
o drop_receiving_element
o sortable_element
o visual_effect
o RJS
o hide
o insert_html
o remove
o replace
o replace_html
o show
o toggle
Click here.
Filed Under (General) by Wenbert on 21-10-2007
Here is an excerpt from a book - Beginning Ajax with PHP: From Novice to Professional.
While the concept of Ajax contains a handy set of functionality for creating actions on the fly, if you are not making use of its ability to connect to the server, you are really just using basic JavaScript. Not that there is anything truly wrong with that, but the real power lies in joining the client-side functionality of JavaScript with the server-side processing of the PHP language using the concept of Ajax.
Throughout this chapter, I will run through some examples of how PHP and Ajax can be used together to design some basic tools that are quite new to Internet applications but have been accessible to desktop applications for ages. The ability to make a call to the server without a page refresh is one that is quite powerful, if harnessed correctly. With the help of the powerful PHP server-side language, you can create some handy little applica-tions that can be easily integrated into any web project.
Why PHP and Ajax?
So, out of all of the available server-side processing languages (ASP, ASP.NET, ColdFusion, etc.), why have I chosen to devote this book to the PHP language, as any of them can function decently with Ajax technologies? Well, the truth is that while any of the afore-mentioned languages will perform admirably with Ajax, PHP has similarities with the JavaScript language used to control Ajax—in functionality, code layout, and ideology.
PHP has been and will likely continue to be a very open form of technology. While code written in PHP is always hidden from the web user, there is a massive community of developers who prefer to share and share alike when it comes to their code. You need only scour the web to find an abundance of examples, ranging from the most basic to the most in-depth. When comparing PHP’s online community against a coding language such as ASP.NET, it is not difficult to see the differences.
JavaScript has always been an open sort of technology, largely due to the fact that it does not remain hidden. Because it is a client-side technology, it is always possible to view the code that has been written in JavaScript. Perhaps due to the way JavaScript is handled in this manner, JavaScript has always had a very open community as well. By combining the communities of JavaScript and PHP, you can likely always find the exam-ples you want simply by querying the community.
To summarize why PHP and Ajax work so well together, it comes down to mere func-tionality. PHP is a very robust, object-oriented language. JavaScript is a rather robust language in itself; it is sculptured after the object-oriented model as well. Therefore, when you combine two languages, aged to maturity, you come away with the best of both worlds, and you are truly ready to begin to merge them for fantastic results.
Client-Driven Communication, Server-Side Processing
As I have explained in previous chapters, there are two sides to a web page’s proverbial coin. There is the client-side communication aspect—that is, the functionality happen-ing right then and there on the client’s browser; and the server-side processing—the more intricate levels of scripting, which include database interaction, complex formulas, conditional statements, and much, much more.
For the entirety of this book, you will be making use of the JavaScript language to handle the client-side interaction and merging it seamlessly with the PHP processing lan-guage for all your server-side manipulation. By combining the two, the sky is truly the limit. Anything that can be imagined can come to fruition if enough creativity and hard work is put into it.
Basic Examples
In order to get geared up for some of the more intricate and involved examples, I will begin by showing some basic examples of common web mini-applications that work well with the Ajax ideology. These are examples you are likely to see already in place in a variety of web applications, and they are a very good basis for showing what can be accomplished using the Ajax functionality.
Beyond the fact that these applications have become exceedingly popular, this chap-ter will attempt to guide you as to what makes these pieces of functionality so well-suited to the Ajax concept. Not every application of Ajax is necessarily a good idea, so it is important to note why these examples work well with the Ajax concept, and how they make the user’s web-browsing experience better. What would the same application look like if the page had to refresh? Would the same functionality have even been possible without Ajax, and how much work does it save us (if any)?
Filed Under (General) by Wenbert on 17-10-2007
Java Passion provides an 18-week AJAX online course for free. I’m not sure if the guy responsible for this was the same guy I saw a couple of years ago in Waterfront Cebu - when I was attending a seminar/conference. He was discussing Java + AJAX along with other Java advocates.
Here is the outline of the course:
In general, the contents (presentation, hands-on labs, and homework’s) will be ready on the dates specified below. Due to the fast pacing nature of the Ajax technology, the contents are constantly being changed and improved even after the dates specified.
- Ajax Basics & Development Tools (Oct 15th, 2007, Week #1)
- JavaScript Basics and DOM APIs (Oct. 22nd, 2007, Week #2)
- Ajax Frameworks and Toolkits (Nov. 5th, 2007, Week #3)
- Ajax Application Examples (Nov. 12th, 2007, Week #4)
- Dojo Toolkit Basics (Nov. 26th, 2007, Week #5)
- Dojo Toolkit Advanced (Dec. 3rd, 2007, Week #6)
- ProtoType (Dec. 10th, 2007, Week #7)
- JSON (Dec. 17th, 2007, Week #8)
- Mashup (Jan. 7th, 2008, Week #9)
- Direct Web Remoting (DWR) (Jan. 4th, 2008, Week #10)
- Google Web Toolkit (Jan. 28th, 2008, Week #11)
- JavaServer Faces (JSF) and Ajax Integration (Feb. 4th, 2008, Week #12)
- jMaki (Feb. 18th, 2007, Week #13)
- Web Application Frameworks and Ajax (Feb. 25th, 2008, Week #14)
- CSS (March 10th, 2008, Week #15)
- Portlet/Portals and Ajax - (March 17th, 2008, Week #16)
- JavaScript Best Practices (April 7th, 2008, Week #17)
- ZK Framework
- Phobos (Script-based MVC framework) (March 31st, 2008, Week #17)
- Dissecting the Java BluePrints Petstore 2.0 Reference Application - work in progress
- Ajax Design Patterns and Best Practices - work in progress
- DynaFaces (April 14th, 2008, Week #18) -
- Commercial framework/tools (Backbase, JackBe, Tibco) - work in progress
Click here for the free training.
|
|