root / docs / www / colonyscout / internal / jeditable / jquery.jeditable.ajaxupload.js @ f59acf11
History | View | Annotate | Download (1.44 KB)
1 |
/*
|
---|---|
2 |
* Ajaxupload for Jeditable
|
3 |
*
|
4 |
* Copyright (c) 2008-2009 Mika Tuupola
|
5 |
*
|
6 |
* Licensed under the MIT license:
|
7 |
* http://www.opensource.org/licenses/mit-license.php
|
8 |
*
|
9 |
* Depends on Ajax fileupload jQuery plugin by PHPLetter guys:
|
10 |
* http://www.phpletter.com/Our-Projects/AjaxFileUpload/
|
11 |
*
|
12 |
* Project home:
|
13 |
* http://www.appelsiini.net/projects/jeditable
|
14 |
*
|
15 |
* Revision: $Id$
|
16 |
*
|
17 |
*/
|
18 |
|
19 |
$.editable.addInputType('ajaxupload', { |
20 |
/* create input element */
|
21 |
element : function(settings) { |
22 |
settings.onblur = 'ignore';
|
23 |
var input = $('<input type="file" id="upload" name="upload" />'); |
24 |
$(this).append(input); |
25 |
return(input);
|
26 |
}, |
27 |
content : function(string, settings, original) { |
28 |
/* do nothing */
|
29 |
}, |
30 |
plugin : function(settings, original) { |
31 |
var form = this; |
32 |
form.attr("enctype", "multipart/form-data"); |
33 |
$("button:submit", form).bind('click', function() { |
34 |
//$(".message").show();
|
35 |
$.ajaxFileUpload({
|
36 |
url: settings.target,
|
37 |
secureuri:false, |
38 |
fileElementId: 'upload', |
39 |
dataType: 'html', |
40 |
success: function (data, status) { |
41 |
$(original).html(data);
|
42 |
original.editing = false;
|
43 |
}, |
44 |
error: function (data, status, e) { |
45 |
alert(e); |
46 |
} |
47 |
}); |
48 |
return(false); |
49 |
}); |
50 |
} |
51 |
}); |