我试图访问ruby" variablename"我的HTML中的变量:
<% array.each_with_index do |variablename, i| %>
<span class="classname">
<a ng-href="/variablename/<%= variablename.gsub(' ', '').strip %>"> <%=variablename.strip %> </a>
</span>
在JS工具提示构造函数中:
$('.classname').ready(function(element) {
Tooltipconstructor.create('.classname', {
ajax: {
type: "GET",
dataType: "JSON",
url: /api/etc/{} // Where I want to access the HTML/Ruby Variable
etc..........
如何访问此变量?谢谢!
答案 0 :(得分:0)
您还可以从a
文字中获取值:
$('.classname').ready(function(element) {
var path = $('.classname > a').text()
Tooltipconstructor.create('.classname', {
ajax: {
type: "GET",
dataType: "JSON",
url: /api/etc/+path // Where I want to access the HTML/Ruby Variable
etc..........