分享2個(gè)jQuery插件--jquery.fileupload與artdialog

這些是我們項(xiàng)目中必不可少的東西,所以今天推薦兩個(gè)一個(gè)叫做artdialog是個(gè)iframe的jquery插件,一個(gè)叫jquery file upload,我看網(wǎng)上很少有這個(gè)插件jquery file upload的插件使用教程,今天我就簡單的介紹和寫一點(diǎn)使用的方法!
簡單用代碼舉例子
最小化的方法
data-url是上傳后執(zhí)行上傳文件的php方法
<input id="fileupload" type="file" name="files[]" data-url="server/php/" multiple>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
<script src="js/vendor/jquery.ui.widget.js"></script>
<script src="js/jquery.iframe-transport.js"></script>
<script src="js/jquery.fileupload.js"></script>
<script>
$(function () {
$('#fileupload').fileupload({
dataType: 'json', //josn傳輸
done: function (e, data) { //上傳結(jié)束后執(zhí)行
$.each(data.result.files, function (index, file) {
$('<p/>').text(file.name).appendTo(document.body);
});
}
});
});
</script>
稍微擴(kuò)展一下
<input id="fileupload" type="file" name="files[]" multiple>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
<script src="js/vendor/jquery.ui.widget.js"></script>
<script src="js/jquery.iframe-transport.js"></script>
<script src="js/jquery.fileupload.js"></script>
<script>
$(function(){
//完整的API在這里https://github.com/blueimp/jQuery-File-Upload/wiki/API 我就是簡單的介紹一些常用的說明
$("#fileupload").fileupload('option',{ //設(shè)置上傳事件
url: 'http://localhost/php/index.php' //指定php上傳方法
disableImageResize: /Android(?!.*Chrome)|Opera/
.test(window.navigator.userAgent), //禁止生成縮略圖
maxFileSize : 5000000 //設(shè)置支持的最大尺寸
acceptFileTypes: /(\.|\/)(rar|zip|jp?g|png|bmp)$/i, //設(shè)置上傳的類型
});
$.ajax({
url: $('#fileupload').fileupload('option', 'url'), //根據(jù)設(shè)置選項(xiàng)ajax傳輸
dataType: 'json',
context: $('#fileupload')[0]
}).done(function (result) {
$(this).fileupload('option','done'
).call(this, $.Event('done'), {result: result}); //上傳完成后做的事情
});
$('#fileupload').bind('fileuploaddone',function(e,data){ //綁定上傳完執(zhí)行的事件
$.each(data.result.files , function (index ,file){
for(var i in file){
alert(i+':'+file[i])
}
});
//綁定的事件太多了 大家直接翻譯過來就明白是什么意思
$('#fileupload')
.bind('fileuploadadd', function (e, data) {/* ... */})
.bind('fileuploadsubmit', function (e, data) {/* ... */})
.bind('fileuploadsend', function (e, data) {/* ... */})
.bind('fileuploaddone', function (e, data) {/* ... */})
.bind('fileuploadfail', function (e, data) {/* ... */})
.bind('fileuploadalways', function (e, data) {/* ... */})
.bind('fileuploadprogress', function (e, data) {/* ... */})
.bind('fileuploadprogressall', function (e, data) {/* ... */})
.bind('fileuploadstart', function (e) {/* ... */})
.bind('fileuploadstop', function (e) {/* ... */})
.bind('fileuploadchange', function (e, data) {/* ... */})
.bind('fileuploadpaste', function (e, data) {/* ... */})
.bind('fileuploaddrop', function (e, data) {/* ... */})
.bind('fileuploaddragover', function (e) {/* ... */})
.bind('fileuploadchunksend', function (e, data) {/* ... */})
.bind('fileuploadchunkdone', function (e, data) {/* ... */})
.bind('fileuploadchunkfail', function (e, data) {/* ... */})
.bind('fileuploadchunkalways', function (e, data) {/* ... */});
});
});
</script>
由于這個(gè)插件功能很強(qiáng)大,方法和API太多大家可以先看看官網(wǎng)的APi,當(dāng)然有不懂的也可以問問我!
第二個(gè)這個(gè)其實(shí)很簡單artdialog,國人開發(fā)的,所有的API都是漢語的,所以同學(xué)們一看就會(huì)了,這里我就說一個(gè)的了,就是iframe關(guān)閉如何傳輸數(shù)據(jù)呢?
<script src="jquery.mini.js"></script>
<script src="artDialog.js?skin=default"></script>
<script src="./plugins/iframeTools.js"></script>
<script src="./skins/idialog.css"></script>
<title>jquery的處理</title>
</head>
<script>
function nihao(){
art.dialog.open( //打開一個(gè)iframe遠(yuǎn)程文件
"http://localhost/dialog/index2.html",
{
title :"測試的頁面",
width: 320,
height: 400,
close : function(){
//iframe關(guān)閉時(shí)執(zhí)行的
alert("my god 關(guān)閉了")
}
}
);
}
</script>
<body>
<input type="text" id="nihao" value="測試數(shù)據(jù)"/>
<a href="javascript::nihao()" onclick="nihao()">提交</a>
我要把index2.html數(shù)據(jù)傳輸回去,當(dāng)然我的index2打算點(diǎn)擊X的時(shí)候就已經(jīng)把數(shù)據(jù)傳輸回父iframe的框架怎么做,下邊代碼
<script src="jquery.mini.js"></script>
<script src="artDialog.js?skin=default"></script>
<script src="./plugins/iframeTools.js"></script>
<script src="./skins/idialog.css"></script>
<title>jquery的處理</title>
</head>
<body>
<input type="text" id="chushu" value="2222111" />
<script>
var origin = artDialog.open.origin;
var v = origin.document.getElementById('nihao');
v.value = document.getElementById('chushu').value;
</script>
當(dāng)然數(shù)據(jù)不是點(diǎn)擊X按鈕的傳輸可以用自帶的art.dialog.data(‘test', val);這種方法來傳輸!!事件匆忙寫的比較緊,大家有不懂的找我就可以了!
- artdialog的圖片/標(biāo)題以及關(guān)閉按鈕不顯示的解決方法
- 給artDialog 5.02 增加ajax get功能詳細(xì)介紹
- artDialog 4.1.5 Dreamweaver代碼提示/補(bǔ)全插件 附下載
- artDialog雙擊會(huì)關(guān)閉對(duì)話框的修改過程分享
- JS中artdialog彈出框控件之提交表單思路詳解
- jQuery validate+artdialog+jquery form實(shí)現(xiàn)彈出表單思路詳解
- artDialog+plupload實(shí)現(xiàn)多文件上傳
- plupload+artdialog實(shí)現(xiàn)多平臺(tái)上傳文件
- jQuery對(duì)話框插件ArtDialog在雙擊遮罩層時(shí)出現(xiàn)關(guān)閉現(xiàn)象的解決方法
- Jquery彈出窗口插件 LeanModal的使用方法
- 使用jQuery插件創(chuàng)建常規(guī)模態(tài)窗口登陸效果
- jQuery插件artDialog.js使用與關(guān)閉方法示例
相關(guān)文章
Javascript技巧之不要用for in語句對(duì)數(shù)組進(jìn)行遍歷
Javascript技巧-不要用for in語句對(duì)數(shù)組進(jìn)行遍歷的一些原因分析,需要的朋友可以參考下。2010-10-10
JQuery異步加載無限下拉框級(jí)聯(lián)功能實(shí)現(xiàn)示例
這篇文章主要介紹了JQuery異步加載無限下拉框級(jí)聯(lián)功能的實(shí)現(xiàn),需要的朋友可以參考下2014-02-02
基于jquery實(shí)現(xiàn)漂亮的動(dòng)態(tài)信息提示效果
這個(gè)效果是在頁面頭部出現(xiàn)的,出現(xiàn)一下會(huì)自動(dòng)隱藏,上面有x那個(gè)提示就要手動(dòng)關(guān)閉一下,其他的都是自動(dòng)隱藏的!2011-08-08
從零開始學(xué)習(xí)jQuery (十) jQueryUI常用功能實(shí)戰(zhàn)
本文是實(shí)戰(zhàn)篇. 使用jQueryUI完成制作網(wǎng)站的大部分常用功能.2011-02-02
利用jQuery的$.event.fix函數(shù)統(tǒng)一瀏覽器event事件處理
做WEB前端開發(fā)的人都知道不同的瀏覽器對(duì)事件的處理方式是有區(qū)別的。2009-12-12
jquery實(shí)現(xiàn)簡單的二級(jí)導(dǎo)航下拉菜單效果
這篇文章主要介紹了jquery實(shí)現(xiàn)簡單的二級(jí)導(dǎo)航下拉菜單效果,涉及jquery鼠標(biāo)事件動(dòng)態(tài)操作頁面元素樣式及Ajax調(diào)用的技巧,具有一定參考借鑒價(jià)值,需要的朋友可以參考下2015-09-09

