javascript - MVC4, initiate work of 25 <a> links from the code -
mvc4. razor view has 100 links: tags "href="@url.action("myaction", "home", new { ...." each link points same "myaction", parameters values different. "myaction" returns fileresult: downloads zip file onto users system. so, user clicks on link -> user gets zip file downloaded on system. now, instead of clicking on 25 links one-by-one download 25 zip files, user wants click 1 button on view download 25 zip files.
for second day trying find way accomplish this, no success. -i trying find way send click event 25 links on page: looks there no way make work. - trying find way call "myaction" 25 times different parameters can please me find way initiate work of 25 links code somehow ? many suggestions
just tested this:
<div><a href="http://2i-it.com/download/file1.rar" class="auto-multi-click">file1</a></div> <div><a href="http://2i-it.com/download/file2.rar" class="auto-multi-click">file2</a></div> <div><a href="http://2i-it.com/download/file3.rar" class="auto-multi-click">file3</a></div> <a href="#" id="download-all">download all</a> <script src="//ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script> <script> $(function () { $('#download-all').click(function () { $('.auto-multi-click').each(function () { var url = $(this).attr('href'); window.open(url); }); }); }); </script>
Comments
Post a Comment