|
JQuery datatable with added FancyBox and auto refresh |
This is relatively straightforward to do, but there are several key concepts to getting everything working correctly, so I've broken it down into a few chunks.
|
Combining JQuery Datatable with drag and drop functions |
The datatables JQuery plugin ( http://www.datatables.net/ ) is an incredibly powerful way of displaying tabular data and allowing the user to manipulate it without leaving the current view.
The plugin already features paging and sorting, but what if you want to extend the plugin with some other non default behaviours like drag and drop? Using a previous example ( http://www.mccran.co.uk/index.cfm/2010/4/29/JQuery-Datatables-plugin-example-using-a-server-side-data-request-coldfusion ) as a starting point I thought I'd try and integrate drag and drop with the datatable object.
|
Handling CFfile upload 'accept' file type errors |
I was working on a system recently that allowed a user to upload images onto the server. It was restricted to files types of images, more specifically 'jpeg' and 'gif' files.
This is easily done with the 'accept' parameter, as documented in the ColdFusion documentation:
2
3Limits the MIME types to accept. Comma-delimited list. For example, the following code permits JPEG and Microsoft Word file uploads:
4accept = "image/jpg, application/msword"
5
6The browser uses the file extension to determine file type.
It is important to note here that it is the browser uses the file extension, so renaming an exe to jpg would fool it entirely.
Issues arise when you don't handle an invalid file upload in a friendly manner. In this case when a user tried to upload an incorrect file type they saw a nasty unformatted error message stating that the request could not be processed as the file was the wrong Mime type.
You cannot tell what the file type is until you attempt to upload it, so wrap your cffile tags in a simple try-catch and handle any errors in the same fashion as you normally would, I.E. by handling the system message and instead displaying a nice, user friendly message that doesn't sound like it was written by robots.
2
3<cffile action="upload" destination="#request.uploadPath#" fileField="form.new_image" accept="image/jpeg, image/gif" nameConflict="overwrite">
4
5<cfcatch>
6
7 <cfset attributes.errors.type = 'error'>
8 <cfset attributes.errors.message = "The type of file you have tried to upload is not allowed, please select a jpg or gif.">
9 <cfset request.continue = false>
10
11</cfcatch>
12
13</cftry>
|
Things I saw at the Gadget show live - Long live the QR Code |
I was recently at the Gadget show live exhibition event at the National Exhibition center in Birmingham. One of the first things I noticed was the proliferation of the QR, Quick Response, code.
It is exactly the right sort of environment for it, being a Gadget and Technology based event, and there are undoubtedly a higher percentage of smart phone users in the crowd, but it was great to see a lot of exhibitors using QR codes on their stands.