javascript - using backward slashes it takes entire path -
- i trying pass path of file , filename alone in grid.
- right working forward slashes not working backward slashes.
- when give whole path using backward slashes takes entire path
- can guys tell me how fix it.
- providing code below
working scenario test/player.txt not working scenario test\player.txt
http://jsfiddle.net/besnpj54/8/
template: "<a onclick=\"window.open('#= filename#', 'popup', 'width=800,height=600,scrollbars=yes,resizable=no')\">#= filename.substring(filename.lastindexof('/')+1) #</a>"
one solution replace \
/
before adding grid. this:
$("#save").click(function(){ grid.datasource.add({"filename":$("#fname").val().replace(/\\/g,"/"),"lastname":"last name"}); $("#fname").val(''); });
http://jsfiddle.net/besnpj54/11/
please note \
used escape special characters (as did \"
), \
have type \\
. more information @ special characters block on page: https://www.w3schools.com/js/js_strings.asp
Comments
Post a Comment