dojo上传功能有用的文章

如何使用dojo的纠结的文件上传功能Uploader?

dojo的文件上传功能,Uploader,为dojo提供了统一的文件上传界面。 可是,这里面有个令人纠结的问题,在几乎探索了一个整天的时间,找到了答案。
因为现在在开发的项目需要分次将文件上传,且对应不同的查核项目。 Dojo的Uploader有个最令人头疼的问题是,在按表单的提交按钮时,会找到目前所有的Uploader控件,然后每个都执行一遍。这简直是一个灾难。并且,由于使用Dojo,表单提交按钮对应着其他的脚本文件,这样会导致目前使用的php文件几乎都要统统改写。
或者这个Uploader在设计的过程中,只是想到一次上载文件,然后虽然提供了立即上传的选项,但是并没考虑清楚业务处理逻辑,实际上导致立即上传几乎无法使用。在Google搜索了半天也没有答案,只好自己动手。

Uploader涉及几个脚本: dojox/form/Uploader.js 这个是个关键。dojo/form/uploader/_Base.js dojo/form/uploader/_HTML5.js
后面两个脚本不需要改动,只是需要将前面的脚本中的submit: 方法注释掉即可。 这样,我们就可使用Uploader中的uploadOnSelect:true,将文件提前上传至服务器器端即可。

复制代码

  1. submit:function(_1b){
  2. /*
  3. _1b=!!_1b?_1b.tagName?_1b:this.getForm():this.getForm();
  4. var _1c=_c.toObject(_1b);
  5. _1c.uploadType=this.uploadType;
  6. this.upload(_1c);
  7. */
  8. }


Re:如何使用dojo纠结的文件上传功能Uploader?How to apply mutiple dojox/form/Uploader

During find the solution,I've found following article in dojo mail list. No reply since it's blocked out of the mailing list:

I have a use case that requires uploading a number of files using a single submit.
Each file must be recognized by the receiving server as being intended for a specific purpose.
(So I can not revert to multi file upload)

Using plain old <input type=file/>elements works fine.
However,trying to use dojo also for the file upload elements
caused my application to break:

Each Uploader widget submits the whole form (excluding any other Uploader instances)
Also,a page returned form the server as a response is received but not displayed.

So,it looks as if normal form submit is superseded by XHR interaction.
.. and this is not useful in my context.

I tried setting force="form" ... with no success.
Inspecting the code showed no support for connecting Uploader with "plain old" form POST delivery.

Is there a way to get several file input elements working in a form using Uploader widgets?
Or is this usecase to be considered completely unsupported?
Did I miss some settings that would ensure the intended behaviour?

Or if Uploader is the wrong widget - what should I use instead?
Or is there at least a way to "enrich" the plain vanilla file input element to look consistent with dojo styling?
Answer:
The solution is to comment the submit method out of dojox/form/Uploader.js at around line 56 as following:

复制代码

  1. submit:function(_1b){
  2. /*
  3. _1b=!!_1b?_1b.tagName?_1b:this.getForm():this.getForm();
  4. var _1c=_c.toObject(_1b);
  5. _1c.uploadType=this.uploadType;
  6. this.upload(_1c);
  7. */
  8. }





Please do not forget to clean the cache of your browser after you've revised the documents.
官方说明

dojox.form.FileUploader

dojox.form.FileUploader

Project owner: Mike Wilcox
Author: Mike Wilcox
since: 1.1

Handles multiple file uploading to a server. DEPRECATED: dojox.form.FileUploader is no longer supported and will be removed in 2.0. Suggested that you use dojox.form.Uploader instead.

Usage

CDN Note

FileUploader does work with the Google and AOL CDNs,but because of cross domain issues,you need to run the SWF locally,and point to its location with dojoConfig.uploaderPath.

Dojo Version 1.2.x

The FileUploader version 1.1 and 1.2 is no longer supported. FileUploader 1.2 programmatically called the Flash browse() method which Adobe soon after removed for security reasons.

Dojo Version 1.3

This version is supported but has limitations. It floats the SWF over the styled button,so the CSS is tricky and not always 100% accurate. And this will not work in many cases where the button is in scrolling content,specifically Windows and Linux Firefox.

Dojo Version 1.3.2

This version is a major upgrade from 1.3,makes CSS placement easier and fixes the scrolling bug. However there is an IE8 bug that was not caught at the time of release. This bug can be patched using the instructions found in the Trac ticket:

http://bugs.dojotoolkit.org/ticket/9615

Another bug found is uploading multiple files more than once causes onComplete to fire on every file. It should only fire after all files have uploaded. The fix for this is to use the SWF from the trunk (1.4) in the 1.3.2 release.

http://bugs.dojotoolkit.org/ticket/9646

Dojo Version 1.4.0

This version has some serious upgrades,including a more robust upload system that has been tested to upload 500 files and 500 megs. This version also fixes several bugs including the ability to display the uploader in a Dialog.

Dojo Version 1.5.0

This version adds the ability to use the uploader in a TabContainer. However,see the next section.

Dojo Version 1.6.0

dojox.form.FileUploader is now deprecated. Use dojox.form.Uploader instead.

IMPORTANT NOTES

There is a serious limitation in the Flash version for Firefox and Safari in TabContainers. When a node in those browsers is hidden (or essentially repainted which can mean other style applications) the SWF is reloaded. This means that if you browse for a file but don’t upload upload it,change the tab and return,the files will no longer be in the FileUploader. This problem can be seen when tabbing between Tab 1 and Tab 2 and observing the console logs and you will see the SWF reinitializes. This problem does not exist in Internet Explorer. The HTML version of the Uploader should also work fine.

See form/tests/test_FileUploaderTabs.html for the workaround. It floats a div above the tab container and moves it on and off screen as the tab is toggled.

While the FileUploader instantiates like a widget,it has limitations due to the fact that it has to manage a Flash plugin. Before it is built,it inspects the DOM and checks style information. Due to this process there needs to be a node to inspect,so dojo 1.4 functionality like:

var f = new dojox.form.FileUploader(props).placeAt(anything);

...will not work. There may also be problems with placing it in other widgets unless it displays right away,although as of 1.5 these problems have mostly been worked out.

If you need to manually manage when an initially hidden flash-based file uploader is shown and have it created properly see this ticket: http://bugs.dojotoolkit.org/ticket/10920

Another limitation with using Flash is passing data back and forth. There is a problem with passing variable names with illegal characters,like:

{form[“my-var”]: “foo”)

Currently the only workaround is to don’t do that.

Updating Your Release

I often suggest to people who are not able to use the 1.3.2 or trunk version of Dojo to copy over the latest uploader files. The involved files would be:

  • dojox/form/FileUploader.js
  • dojox/form/resources/uploader.swf
  • dojox/form/resources/FileUploader.css
  • dojox/embed/flashVars.js
  • dojox/embed/Flash.js

and optionally:

  • dojox/form/resources/UploadFile.php
  • dojox/form/resources/cLOG.php

Note that if you are moving these files into Dojo 1.2 or less,you will have to change some of the code in the FileUploader to not use the 1.3 html method dojo.destroy() and replace it with the previous version of dojo._destroyElement()

FileUploader Functionality 1.3.2 - 1.5

FileUploader is now a widget and DOES create a button. You do not have to pass a button in. Passing a button is still supported until version 1.5 to maintain backwards compatibility,but it is not recommended. In a majority of cases,you can create your uploader like any other widget.

Setup

The button styles are now recreated in Flash,so there is no longer an invisible Flash movie with wmode=transparent. This way the Flash button is actually placed inline with the DOM,not floating above it and constantly resetting its position. The “Windows Firefox clickable bug” should be fixed (and hopefully some Linux problems).

The HTML button is created in a new way and it is now inline as is the Flash button. Styling is much easier and more versatile.

The process is to create a typical HTML button,with either a button,input,div,or span tag. Button tags work the best. Style the button how you would like it to look in CSS. Then create another class that will append to the class chain to style the button in its hover state. Follow the same procedure for active state (press) and disabled state. Assign the normal class to your button and make the widget either programmatically or with markup.

A basic example follows:

.uploadBtn{
    border:1px solid #333333;
    background:url(buttonEnabled.png) #d0d0d0 repeat-x scroll 0px top;
    font-size:14px;
    width:201px;
    height:30px;
    vertical-align:middle; /* emulates a <button> if node is not */
    text-align:center;
}
.uploadHover{
    background-image:url(buttonHover.png);
    cursor:pointer;
    font-weight:bold;
}

.uploadPress{
    background-image:url(buttonActive.png);
}
.uploadDisabled{
    background-image:none;
    background-color:#666;
    color:#999;
    border:1px solid #999;
}
<div id="btn" class="uploadBtn">Select Files</div>
var uploader = new dojox.form.FileUploader({
    hoverClass:"uploadHover",
    activeClass:"uploadBtn",
    pressClass:"uploadPress",
    disabledClass:"uploadDisable",
    uploadUrl:pathToUploadServerScript
}, "btn");

Or,using the same CSS,create it as markup:

<div class="uploadBtn" data-dojo-type="dojox.form.FileUploader" data-dojo-props="hoverClass:'uploadHover',pressClass:'uploadPress',
     activeClass:'uploadBtn',disabledClass:'uploadDisable',uploadUrl:'../serverpage.php'">Select Files</div>

Dependencies

FileUploader no longer uses FileInput.css. It now uses FileUploader.css. See requires for JavaScript dependencies.

New Features

  • Disabled: Can be toggled with widget.set(“disabled”,true|false)
  • Submit: A convenience method has been added for if the uploader is in a form. Instead of submitting the form,call uploader.submit(theForm),and the Uploader will handle all of the form values and post the data.
  • Selected List: If passing the ID of a container,the Uploaders will populate it with the selected files.
  • Deleting Files: You can now delete pending files.
  • Progress Built in: showProgress:true will change the button to a progress bar on upload.
  • Progress Attach: Passing progressWidgetId will tell the Uploader of a progress widget. If the Progress widget is initially hidden,it will change to visible and then restored after upload.
  • A11Y: The Flash button can be accessed with the TAB key. (The HTML cannot due to browser limitations)
  • Deferred Uploading: (Flash only) throttles the upload to one file at a time

Changed in 1.4: deferredUploading is now mandatory to prevent errors in Firefox and Safari. It accepts a number and the idea is you can upload more than one file in parallel,though my tests have shown it always does one at a time anyway. This change makes the upload a little slower,but now it is much more robust and can handle uploads of 500 files or more without crashing the browser.

There are two new tests added to DojoX: test_FileUploaderCSS.html and test_FileUploaderForm.html. The form test will show how to implement most of the new features. The CSS test will show different methods of styling the Uploader.

http://mwilcox.dojotoolkit.org/dtk/dojox/form/tests/test_FileUploaderForm.html

http://mwilcox.dojotoolkit.org/dtk/dojox/form/tests/test_FileUploaderCSS.html

Continue with the 1.3 instructions for other information that still applies to implementing the FileUploader.

Version 1.3

Version 1.3 does NOT create a button - it transforms an existing button into an uploader. This can be used for toolbar buttons for example. Because of this,it only works programmatically,it does not work in markup. Use the other other DojoX FileInput files for markup solutions.

FileUploader will detect if the correct version of Flash Player is available,and if so,a transparent SWF is laid over the top of the original (referred to as the ‘fake’) button. If not available,a traditional fileInput button with opacity set to zero is laid over the fake button.

A basic example follows:

var uploader = new dojox.form.FileUploader({
    button:dijit.byId("myFakeButton"),
    uploadUrl:uploadUrl,
});

The example has doesn’t show selectMultipleFiles,but it defaults to true. Setting it to false restricts the user to one file selection. Multiple files are also supported in the HTML version,although only one file can be selected at a time. But after the files are selected,they will all be uploaded at once.

The uploadUrl property is the location of the server side script. Note that this URL needs to be relative to the SWF,not to the HTML page,nor to dojo.js. It’s recommended that an absolute URL is used if possible. FlashUpload will try to “normalize” relative URLs and point them to the SWF.

Use dojo.connect to connect to the onChange,onProgress and onComplete methods:

dojo.connect(uploader, "onChange", function(dataArray){
    dojo.forEach(dataArray, function(data){
        dojo.byId("myTextarea").value += data.name+" "+Math.ceil(data.size*.001)+"kb \n";
    });
});
dojo.connect(uploader, "onProgress", function(data){
        dojo.byId("myTextarea").value += "onProgress: ("+data.percent+"%) "+data.name+" \n";
    });
});
dojo.connect(uploader, "onComplete", function(d){
        dojo.byId("myTextarea").value += "onComplete: "+d.file+" \n";
    });
});

Use upload to initiate the upload after files have been selected. Or set uploadOnChange to true to initiate upload automatically after the selection.

Note that the “dataArray” param above is always an array,even if selectMultipleFiles is set to false.

Updated: Be careful not to construct the connect so that it sends a mouse event to the upload method (as this example used to do). The upload method expects no arguments or one argument to use as postData. The mouse event will be treated as postData and throw an error. This is fixed in the trunk but exists in 1.32.

dojo.connect(dijit.byId("myUploadButton"), "onClick", function(){
    uploader.upload();
});

Advanced Parameters

The FileUploader has many advanced properties to handle most situations.

fileMask: An array,or an array of arrays. Restrict file selection to certain file types Empty array defaults to “All Files”. NOTE: MacType is not supported,as it does not work very well. fileMask will work on a Mac,but differently than Windows.

var fileMask = ["Images", "*.jpg;*.jpeg;*.gif;*.png"]
// or
var fileMask = [
    ["Jpeg File",  "*.jpg;*.jpeg"],
    ["GIF File",   "*.gif"],
    ["PNG File",   "*.png"],
    ["All Images", "*.jpg;*.jpeg;*.gif;*.png"],
];
var uploader = new dojox.form.FileUploader({
    button:dijit.byId("myFakeButton"),
    fileMask:fileMask
});

force: You can use either HTML (force=”html”) or Flash only,with this parameter. If force=”flash” and the user does not have Flash installed,they will be prompted to install the plugin. “flash” forces Flash Uploader. Defaults to an empty string (force=””) which checks for the availability of the proper Flash player (Flash 9 or higher).

postData: The data that will be sent via POST to the server along with the uploaded files. This data object can bet set on instantiation,and the data will be sent to the server with each file on every upload. You can also pass postData in the upload method as an object argument which can be different with each upload.

Note: as of 1.4.0 there is a bug: http://bugs.dojotoolkit.org/ticket/10559 where postData is not being sent for flash based uploaders where uploadOnChange is also true. This is fixed in 1.5.

Returned postData: Post data is regurgitated to the uploader in the tests. Your case may be different. The SWF returns postdata in an additionalParams object,and it is in this object in which the postdata can be found in the onComplete object. The reason for this was originally to get around AS3 issues,but it turns out to be a good system,as it prevents post data variables from overwriting standard variables such as ‘name’ or ‘file’.

htmlFieldName: The name of the field of the fileInput that the server is expecting. See “Server Side Code” below.

flashFieldName: The name of the field of the flash uploaded files that the server is expecting. See “Server Side Code” below.

Dependencies

dojox.html.styles to create dynamic CSS for an IE workaround.dojo.io.iframe for the HTML POST upload.dojox.embed.Flash for embedding the SWF in the page.dojox/form/resources/FileInput.css for some fileInput styling.

Debugging

Because of the complex nature of the FileUploader code (or more accurately,the hack!). It’s often necessary to do some debugging to test if something is working properly. The following parameters assist with this:

isDebug: Unlike most Dojo code,the logging has been left in the FileUploader,but is disabled by default. isDebug=true will turn on the log messages for inspection. This also passes to the SWF which will output messages of what’s happening in there.

devMode: Changing this parameter to true will set the opacity of the HTML upload button to 100% and remove transparency from the Flash upload button. This helps to determine of the button is being positioned correctly.

Server Side

The transfer of data happens through Flash and so the you will not be able to inspect the data in Firebug. It’s recommended to use Charles or Fiddler if you wish to inspect the transfer.

http://www.charlesproxy.com/

http://www.fiddler2.com/fiddler2/

The following transfer example is taken from:

http://livedocs.adobe.com/flash/9.0/ActionScriptLangRefV3/flash/net/FileReference.html

It includes examples two post parameters,api_sig and api_key. The name for the field where the file can be found is set to “photo” (Adobe default is “FileData” and FileUploader changes this default to “flashUploadFiles”).

POST /handler.cfm HTTP/1.1
  Accept: text/*
  Content-Type: multipart/form-data;
  boundary=----------Ij5ae0ae0KM7GI3KM7ei4cH2ei4gL6
  User-Agent: Shockwave Flash
  Host: www.example.com
  Content-Length: 421
  Connection: Keep-Alive
  Cache-Control: no-cache

  ------------Ij5GI3GI3ei4GI3ei4KM7GI3KM7KM7
  Content-Disposition: form-data; name="Filename"

  MyFile.jpg
  ------------Ij5GI3GI3ei4GI3ei4KM7GI3KM7KM7
  Content-Disposition: form-data; name="api_sig"

  XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
  ------------Ij5GI3GI3ei4GI3ei4KM7GI3KM7KM7
  Content-Disposition: form-data; name="api_key"

  XXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
  ------------Ij5GI3GI3ei4GI3ei4KM7GI3KM7KM7
  Content-Disposition: form-data; name="auth_token"

  XXXXXXXXXXXXXXXXXXXXXX
  ------------Ij5GI3GI3ei4GI3ei4KM7GI3KM7KM7
  Content-Disposition: form-data; name="photo"; filename="MyFile.jpg"
  Content-Type: application/octet-stream

  FileDataHere
  ------------Ij5GI3GI3ei4GI3ei4KM7GI3KM7KM7
  Content-Disposition: form-data; name="Upload"

  Submit Query
  ------------Ij5GI3GI3ei4GI3ei4KM7GI3KM7KM7--

Whether HTML or Flash,the payload is done with a multipart transfer. The file data is uploaded to a temp folder on the server. After the upload is complete,the server script is called. It is the job of the server script to know where this temp folder is and access the file (to move it to the destination,and or perform tasks upon it).

During a Flash multi-file upload,the images are uploaded in parallel (unless FileUploader.deferredUploading=true),however,the server script only receives one file at a time. So if five files are uploaded,the server script will be called five times.

During an HTML multi-file upload,the files are all uploaded at once,and after all five are completely uploaded to the temp folder,the server script is called just once. Each file will be referenced as numerically sequenced fields: uploadedfile0,uploadedfile1,uploadedfile2,etc. Single file uploads will of course call the server script once.

With a multipart request the POST data is the contents for the first part and the uploaded files is an array (or an object) of each additional part. Refer to your particular server documentation for how to reference the files (PHP is used as an example in the next section).

The return data needs to be formatted very specifically,ad there are different formats for Flash and HTML. See Server Side Return Data below.

Server Side Code PHP

FlashUploader comes with a working PHP file,dojox/form/resources/UploadFile.php,to use as a reference for how your server side code should work. UploadFile.php has two dependencies,dojo/tests/resources/JSON.php,which is used for converting the return data to a JSO string,and dojox/form/resources/cLog.php which is used to log message to a text file,placed relative to the PHP file.

UploadFile.php is expecting one of three things:

  1. A file or files from Flash
  2. A file from HTML
  3. Multiple files from HTML

The PHP file is inspecting the header and looking for the parameters set in FileUploader: htmlFieldName or flashFieldName. Whatever you set these parameters to,they must match on the server. The current code uses "flashUploadFiles" as the default Flash field name. (The default field name in Flash is "Filedata",which is over written to show that you can do custom field names). Therefore the server must be made aware of this parameter,as it is set on line 69: $fieldName = "flashUploadFiles";

The field name for the HTML uploader works much the same way. The only difference is if you do multi-file upload with HTML,this essentially continues to add fileInputs to the form,and in doing so,appends numbers to the fileInput field names,starting with '0'. That's why one file fieldname will look like "myFieldName" but two files will look like [ "myFieldName0","myFieldName1" ] to the server side code.

Server Side Return Data

How the data is returned from the server is not difficult,but it is very important. If not done correctly,it can be the cause of reported errors that the "onComplete" is not firing in FileUploader.

NOTE The Flash uploader and the HTML uploader need differently formatted return data. You will need to inspect the post data to determine which type to return.

If flashFieldName is found in the post data and Flash is being used on the client side,all that is needed for return data is a key-value string,and it can simply be returned,as at the end of a function. You may also want to insert exit or whatever necessary to cease execution of the remainder of the code. Example:

$data .='file='.$file.',name='.$name.',width='.$width.',height='.$height.',type='.$type;
echo($data);
exit;

For non-PHP devs this translates to:

$name = name of the file,such as "PIC01.jpg"
$file = name of the file and the path,such as "uploaded/PIC01.jpg"
$width,$height = the dimensions (if you are working with images)
$type = the extension of the file - JPG,GIF,PNG,etc.

The return to Flash should look like:

"file=uploaded/PIC01.jpg,name=PIC01.jpg,width=320,height=240,type=jpg"

This string should be returned,or printed,or echoed.

New in 1.4,you can add an error key if one file was in error; say if it was not of the correct type. This error code or message will be returned in the onComplete dataArray. It's important to note that as far as the FileUploader is concerned,everything was a success. It's up to your custom code to test for this error.

The return string with an error might look like:

"file=uploaded/PIC01.jpg,type=jpg,error=Not recognized file type"

You can also send back arbitrary parameters from your server-side script using this comma-delimitted format. For example,adding variables foo and abc:

"file=uploaded/PIC01.jpg,foo=bar,abc=123"

Then you can access these variables in the client-side functions using dataArray[i].additionalParams.foo and dataArray[i].additionalParams.abc.

Note: there is an open ticket http://bugs.dojotoolkit.org/ticket/10576 - when the uploader is set/forced to HTML mode,additionalParams is not created on the client side. In the situation above dataArray[i].foo would exist though.

If htmlFieldName is used,the code on the client side gets pretty tricky,as an iframe is necessary for the file-post,and reading back from that iframe presents problems. In order to read the iframe return data accurately cross browser,the code needs to be wrapped in a <textarea>. You can see the code for this on the very last line of UploadFiles.php. Note that the textarea needs to be outside of the PHP. Example:

<?php
    ....code....
?>
<textarea><?php print $json->encode($dataObject); ?></textarea>

For non-PHP devs,this translates into a JSON string,wrapped in a textarea,returned as HTML. I know it's screwy,but that's how it works.

If you are having problems getting onComplete to fire,look at this code first. Often the problem is the server side code is not catching the flash field name for whatever reason (perhaps the client and server names don't match) and the code is falling to the end of the page and returning a textarea to Flash. Recently Code has been added in the SWF that checks for this,so if that is the problem,you should be notified with a console message.

HTTPS Issues

Attempting to upload to an HTTPS server can be very difficult in Firefox and Safari due to the fact that they do not share the same session as the browser page. IE has much fewer issues. Potential workarounds (mostly unverified as I do not have an HTTPS server to test with):

  • Here is the official Adobe bug report on the issue: https://bugs.adobe.com/jira/browse/FP-226
  • Firefox does not like self signed security certificates. It has been said that an official signed cert will work.
  • It was brought to my attention that an .htaccess files on the server will work with the following content:
<IfModule mod_security.c>
  SecFilterEngine Off
  SecFilterScanPOST Off
</IfModule>

HOWEVER,this site says that opens you up to SQL injection attacks. He offers other solutions:http://pumastudios.com/2009/05/file-uploads-and-mod_security-vs-wordpress-wp-adminadmin-ajaxphp

The original poster responds:

This is not only a https issue. It's also on simple http connections. Ist a bug of adobe flash player in conjunction with the web application firewall (modsecurity). If i understand that correctly the flash player sends one "\n\r" instead but the http protocol requires "\n\r\n\r". For modsecutiry this is a rule break so it delivers 403 rejected.

And yes if you disable modsecurity sql injections can be done on all post vars that are later processed by the database an not escaped within the application. So another safer way - until adobe fixed this problem and all flash players are updated - is the following but may not work on all servers:

<IfModule mod_security.c>
 SetEnvIfNoCase Content-Type "^multipart/form-data;" "MODSEC_NOPOSTBUFFERING=Do not buffer file uploads"
</IfModule>

(Thanks to minobun for all the great info on this thorny issue)

The other,less desirable solutions,are:
  • Have an HTTP server to handle the uploads and use a crossdomain.xml file to handle the different protocol.
  • You may need to resort to force the HTML uploader.
More references to this issue:

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐


我有一个网格,可以根据更大的树结构编辑小块数据.为了更容易知道用户保存了什么,我希望当用户第一次看到网格时,网格处于不可编辑状态.当用户准备好后,他们可以单击编辑按钮,这将使网格的某些部分可编辑.然后,有一个保存或取消按钮可以保存更改或还原.在大多数情况下它是有效的.但
我即将开始开发一款教育性的视频游戏.我已经决定以一种我可以轻松打包为Web,Mobiles和可能的Standalone版本的方式来实现这一目标.我不想使用Flash.因此,我确信(无论如何我会听取建议)使用JavaScript和SVG.我正在对这个问题进行大量研究,但我很难把各个部分放在一起.我知道Raphae
我正在使用带有Grails2.3.9的Dojo1.9.DojoNumberTextBox小部件–我在表单中使用–将固定格式(JavaScript基本格式)的实数值(例如:12.56)设置为HTML表单输入字段(但根据浏览器区域设置显示/编辑它们,所以用户总是看到格式正确的数字).另一方面,Grails期望输入字段根据浏览器
1.引言鉴于个人需求的转变,本系列将记录自学arcgisapiforjavaScript的学习历程,本篇将从最开始的arcgisapiforjavaScript部署开始,个人声明:博文不在传道受业解惑,旨在方便日后复习查阅。由于是自学,文章中可能会出现一些纰漏,请留言指出,不必留有情面哦!2.下载ArcGISforDe
我正在阅读使用dojo’sdeclare进行类创建的语法.描述令人困惑:Thedeclarefunctionisdefinedinthedojo/_base/declaremodule.declareacceptsthreearguments:className,superClass,andproperties.ClassNameTheclassNameargumentrepresentsthenameofthec
我的团队由更多的java人员和JavaScript经验丰富组成.我知道这个问题曾多次被问到,但为了弄清楚我的事实,我需要澄清一些事情,因为我在客户端技术方面的经验非常有限.我们决定使用GWT而不是纯JavaScript框架构建我们的解决方案(假设有更多的Java经验).这些是支持我的决定的事实.>
路由dojo/framework/srcouting/README.mdcommitb682b06ace25eea86d190e56dd81042565b35ed1Dojo应用程序的路由路由FeaturesRoute配置路径参数RouterHistoryManagersHashHistoryStateHistoryMemoryHistoryOutletEventRouterContextInjectionOutl
请原谅我的无知,因为我对jquery并不熟悉.是否有dojo.connect()的等价物?我找到了这个解决方案:http:/hink-robot.com/2009/06/hitch-object-oriented-event-handlers-with-jquery/但是没有断开功能!你知道jquery的其他解决方案吗?有jquery.connect但这个插件在我的测试中不起作用.
与java类一样,在dojo里也可以定义constructor 构造函数,在创建一个实例时可以对需要的属性进行初始化。//定义一个类mqsy_yjvar mqsy_yj=declare(null,{     //thedefaultusername    username: "yanjun",          //theconstructor   
我一直在寻找一些最佳实践,并想知道Dojo是否具有框架特定的最佳实践,还是最好只使用通用的Javascript标准?特别是我主要是寻找一些功能和类评论的指导方针?解决方法:对于初学者来说,这是项目的风格指南:DojoStyleGuide
我有’05/17/2010’的价值我想通过使用dojo.date.locale将其作为“2010年5月17日”.我尝试过使用dojo.date.locale.parse,如下所示:x='05/17/2010'varx=dojo.date.locale.parse(x,{datePattern:"MM/dd/yyyy",selector:"date"});alert(x)这并没有给我所需的日期
我正在尝试创建一个包含函数的dojo类,这些函数又调用此类中的其他函数,如下所示:dojo.provide("my.drawing");dojo.declare("my.drawing",null,{constructor:function(/*Object*/args){dojo.safeMixin(this,args);this.container=args[0];
我知道你可以使用jQuery.noConflict为jQuery做这件事.有没有办法与Dojo做类似的事情?解决方法:我相信你可以.有关在页面上运行多个版本的Dojo,请参阅thispage.它很繁琐,但似乎是你正在寻找的东西.一般来说,Dojo和jQuery都非常小心,不会破坏彼此或其他任何人的变量名.
我有一个EnhancedGrid,用户经常使用复杂的过滤器.有没有办法允许用户保存或标记过滤器,以便将来可以轻松地重新应用它?我知道我可以通过编程方式设置过滤器,但我无法预测用户想要的过滤器.谢谢!编辑:自己做了一些进展…使用grid.getFilter()返回过滤器的JSON表示,然后使用json.strin
我有这个代码:dojo.declare("City",null,{constructor:function(cityid,cityinfo){}});dojo.declare("TPolyline",GPolyline,{constructor:function(points,color){},initialize:function(map){});应该是什
我遇到的问题是我的所有javascript错误似乎来自dojo.xd.js或子模块.我正在使用chrome调试器和许多dijit功能,如dijit.declaration和dojo.parser.这有点烦人,因为它很难找到简单的错误或滑倒.我希望我可以添加一个选项,允许我的调试器在我的非dojo代码中显示选项会发生的位置.我是
我正在使用DojoToolkit数字/解析函数来处理格式化和使用ICU模式语法解析字符串.有没有人知道有可能采取任意ICU模式字符串并以某种方式使用Dojo(或其他)库将其分解为它的部分(例如,对于数字模式,它可以被分解为小数位数,数千个分组等…).我希望这样做,而不需要让我的代码密切了
我有两个看似相关的问题,访问在不同的地方定义的javascript函数.我遇到的第一个问题是调用我在firgbug或safari控制台中定义的函数.我定义了一个名为getRed的函数,如下所示:functiongetRed(row,col){//dosomethingstuffandreturntheredvalueasa
我想添加一个在Ajax调用中指定的外部样式表.我已经找到了一种方法来使用jQuery(参见下面的示例),但是我需要使该方法适应dojoJavaScript框架.JQuery示例$('head').append('<linkrel="stylesheet"type="text/css"href="lightbox_stylesheet.css">');谢谢.解决方法:一旦你
我正在尝试使用dojo.connect将onMouseDown事件连接到图像,如:dojo.connect(dojo.byId("workpic"),"onMouseDown",workpicDown);functionworkpicDown(){alert("mousedown");}类似的代码几行后,我将onMouse*事件连接到dojo.body确实完全正常工作.但是当我点击图像时