[英]Accessing a Ruby Variable from Inside of an HTML class and Using it In a JS Function
我正在嘗試從我的HTML訪問ruby“variablename”變量:
<% 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..........
我該如何訪問這個變量? 謝謝!
您也可以從值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..........
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.