November 2008
Monthly Archive
Tue 25 Nov 2008
Many people are perhaps still a little unclear of what jQuery Impromptu really is. Its not just a lightbox or dialog. Its actually a small framework to process forms utilizing ajax; and along the way it happened to solve the ugly default confirm and alert problem.
It works by first allowing the user to supply html for display in the prompt. The user can supply as many fields as they like and style them to fit their needs. Then, with strategic callback functions you can validate and/or complete the prompt form. The common framework example is generally defined like the following:
$.prompt(txt,{
buttons:{Ok:true, Cancel:false},
submit: function(v,m){
//parameter v is the value clicked, m is the message at the time it was submitted
//validate our fields, return true if it validates, false if not
//returning false will hold the prompt open
//returning true will proceed to the callback function
},
callback: function(v,m){
//we passed validation process our form!
}
});
This small framework will allow you to process forms consistently, so no matter what type form you’re processing, you can they all follow the same process. Taking it one step further, lets say we need to retrieve all the values in our form so we can validate them. We would add a line like the following:
$.prompt(txt,{
buttons:{Ok:true, Cancel:false},
submit: function(v,m){
var vals = m.find(':input');
if(v){
//user clicked 'Ok', so validate
}
},
callback: function(v,m){
var vals = m.find(':input').serializeArray();
if(v){ //send with Ajax!
$.post('mypage.php',{ var0: vals[0].value },function(){});
}
}
});
There you have it, about as simple as it gets for ajax forms. Download it and give it a whirl, or look at a couple demos.
Tue 18 Nov 2008
I was thumbing through Digg today when I come across an article showing “12 Excellent Free Text Editors“. I’ve tried a few of these, infact I do like a few of them for what they are, but after recently using Coda and Textmate I have to admit these two really set the standard for doing web based work. The simplicity of using each one, yet the necessity features. By necessity I am referring to syntax highlighting, file browser, code suggest, and maybe snipplets and searching through files are useful too.

That being said I have to say the editor under the Linux developer’s nose might not be far off pace. gEdit has a few plugins that make it very good. The file browser plugin is supurb and easy to switch themes for syntax highlighting is very nice. However its key feature missing is code completion/suggest. With the vast amount of javascript, php, CF functions its nearly impossible to remember each one, or the fact of not typing those_long_function_names.

Then there is Geany. Similar to gEdit, it has a file browser plugin, but more importantly has code suggest. But of course I have one small issue. The file browser only browses one directory at a time, no tree structure. I know that sounds picky, but when you’re looking at your directory structure or files in use it is very helpful to see what files are where
So my fantasies are that gEdit have code suggest(not from the current document, but from the language API reference) and/or Geany have a tree structured file browser. These plugins may already exist, but I haven’t found them. If anyone has any suggestions on other editors to give a try on linux I would love to hear about them!
Wed 12 Nov 2008
Posted by trent under
LinuxNo Comments
After upgrading Ubuntu to 8.10 I was upset to find out that my virtual hosts in apache no longer seem to work. Everything went to the default host. After doing a little research I found that in ports.conf they have now specified the port in NameVirtualHost:
NameVirtualHost *:80
When it use to be:
NameVirtualHost *
I tried changing this NameVirtualHost back to the old way but that seemed to give me more errors. The solution to this is to find wherever you have your VirtualHost declared(could be in /etc/apache2/httpd.conf or in the site’s conf files in /etc/apache2/sites-enabled) and add :80 to it like the following:
<VirtualHost *:80>
ServerName test.localhost
DocumentRoot /home/username/www/test/
</VirtualHost>
Then you just need to restart Apache:
sudo /etc/init.d/apache2 restart
Hope this helps someone out, surely helped me!
Sun 9 Nov 2008
I’m please to say that there is a new Impromptu theme available on the Impromptu Documentation site. The theme is demonstrated in Example 15. I have also upgraded the examples and demos to use the latest jQuery. No changes to Impromptu were necessary in the jQuery 1.2.6 upgrade!
Mon 3 Nov 2008
Lately I’ve had a few users indicate they’ve had errors in Impromptu only with IE. I finally was able to replicate this error. The error indicates that its on line 89:
jqi.css({ position: “absolute”, top: “100px”, left: “50%”, marginLeft: ((((jqi.css(”paddingLeft”).split(”px”)[0]*1) + jqi.width())/2)*-1) });
I had been using Impromptu all week and it had been working fine in all browsers. Then I finally received this error I’ve heard so much about. The problem ended up being in the html I passed when invoking the prompt.
$.prompt('<p>this had broken html</p>');
With the html passed in broken jQuery in IE was unable to figure out the proper html and thus could not apply the styling to it. I hope this helps the users out who were having trouble!