Jump to content

drag and drop jslint error


tryingtolearn

Recommended Posts

Im following some examples for drag and drop file uploads and have come across the same for loop in different tutorials

And get the following error (jslint)

The loop

for (i = 0, f; f = files[i]; i++) {
ParseFile(f);
UploadFile(f);

}

The error


 

Expected a conditional expression and instead saw an assignment

 

 

I tried omitting it and adding a break in the loop but it gave the same error on the break line.

 

Trying to figure out an explanation for the error 

 - or a way to re write the second statement to pass through jslint

 

 

Link to comment
Share on other sites

This seemed to do the trick

Not exactly sure what throws the error above or why its considered an error since both versions work..

// file selection
	function FileSelectHandler(e) {
        var i,
            files,
            f;

		// cancel event and hover styling
		fileDragHover(e);

		// fetch FileList object
		files = e.target.files || e.dataTransfer.files;

		// process all File objects
        for (i = 0; i <= files.length - 1; i = i + 1) {
            f = files[i];
            parseFile(f);
            uploadFile(f);
        }
    }
Edited by tryingtolearn
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.