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
https://forums.phpfreaks.com/topic/295285-drag-and-drop-jslint-error/
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);
        }
    }

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.