Last active
September 14, 2015 21:01
-
-
Save r4fx/3f0ed09e5930c5ef9e21 to your computer and use it in GitHub Desktop.
Scroll to uploaded file after upload in long form
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$(function () { | |
var locationHashObjTop = false; | |
$('input[type="submit"]').on('click', function () { | |
var $locationHashObj = $(this).prev(); | |
var locationHash = '#' + $(this).prev().attr('id'); | |
locationHashObjTop = $locationHashObj.offset().top; | |
sessionStorage.setItem('fileHash', locationHash); | |
sessionStorage.setItem('fileHashTop', locationHashObjTop - 150); | |
}); | |
var fileHash = sessionStorage.getItem('fileHash'); | |
locationHashObjTop = sessionStorage.getItem('fileHashTop'); | |
if (locationHashObjTop) { | |
$('html,body').scrollTop(locationHashObjTop); | |
} | |
$('button[type="submit"]').on('click', function () { | |
sessionStorage.removeItem('fileHash'); | |
sessionStorage.removeItem('fileHashTop'); | |
}); | |
//console.log(fileHash + ' : ' + locationHashObjTop); | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment