{% block reviewresult %}
<div class="scrollerList">
</div>
{% endblock %}
{% block myJavascript %}
<script>
var stateObject = {};
var title = "Single";
var urlEncode = "'" +{{ tag|url_encode(true) }} + "'";
alert(urlEncode);
var newUrl = baseUrl + "/taglist/" + urlEncode.toString();
$(document).ready(function() {
ShuffleObj.changeUrl(stateObject, title, newUrl);
ffleObj.setScrollUrl(baseUrl + '/taglist/playlist/' + urlEncode.toString());
});
</script>
{% endblock %}
行var urlEncode = "'" +{{ tag|url_encode(true) }} + "'";
中的上述代码显示错误
SyntaxError:标识符在数字文字后立即开始。在此问题中,代码值为tag= 123 Forever;
答案 0 :(得分:2)
此:
var urlEncode = "'" +{{ tag|url_encode(true) }} + "'";
将生成以下代码:
var urlEncode = "'" + someTag + "'";
并且js将someTag解释为标识符。所以,试试这个:
var urlEncode = ' {{ tag|url_encode(true) }} ';