Easily prevent Flash of Unstyled Content (FOUC) with jQuery
I have a project which uses jQuery UI for tables (formatting), buttons, tabs, etc. Even though my local resources and remotely hosted ones are saved in the browser’s cache, I still have situations where a FOUC (Flash of Unstyled Content) occurs. Read more
Make the jQuery UI Datepicker use a jQuery Button
It has been bugging me for some time that the datepicker widget uses a normal button unless you tell it to use an image. Seeing that we are using the jQuery-UI framework, it makes sense to me that the button should be styled as such. After playing with the selectors and trying it a few different ways, here is how I made that boring datepicker button become a jQuery-UI button (with calendar icon). Read more
Submit ajax form in jQuery-UI Dialog with Enter Key
This question is posted quite a bit and nobody seems to be able to provide a good solution that won’t behave questionably. So here’s my take on it…
$('<div id="myDialog"></div>').appendTo('body').dialog({
autoOpen: false,
modal: true,
closeOnEscape: true,
buttons: {
OK: function() {
$.ajax({
type: 'POST',
url: 'save.php',
data: $('#myDialog :input').serialize(),
error: function(xml, status, error) {
$('#myDialog').html('<p><strong>Error Code:</strong> '+status+'</p><p><strong>Explanation:</strong> '+error+'</p>');
}
});
},
Cancel: function() {
$(this).dialog('close');
}
},
open: function() {
$(this).html('').load('form.php');
},
focus: function() {
$(':input', this).keyup(function(event) {
if (event.keyCode == 13) {
$('.ui-dialog-buttonpane button:first').click();
}
});
}
});
Note: You can also trigger the event on any element (not just form fields) by using $(this) as the selector.
That’s it, enjoy
Change CodeIgniter’s Form_validation error delimiters globally!
I have seen this question all over the web and am surprised that nobody has actually offered such a simple solution.
Anyway, here is a quick, simple and painless way to set CodeIgniter’s error delimiters (used by the Form_validation library) one time for your entire application. Create “application/libraries/MY_Form_validation.php” with the following contents… Read more
Easily load multiple views with CodeIgniter
It is not uncommon to load a common header, footer and other views in each controller. While this can be achieved like so…
$this->load->view('header', $header_data);
$this->load->view('content', $content_data);
$this->load->view('footer', $footer_data);
I wanted the ability to do the same thing with a single line of code. So I decided to extend the core Loader library by creating “application/core/MY_Loader.php” with the following code… Read more
