-1
我想用jquery selectable替換我的醜陋複選框。我將此代碼添加到了我的form_for中,但我不知道如何將tag_list數組傳回給我的控制器。傳遞一個JavaScript數組到軌道控制器
<meta charset="utf-8" />
<link rel="stylesheet" href="http://code.jquery.com/ui/1.9.1/themes/base/jquery-ui.css" />
<script src="http://code.jquery.com/jquery-1.8.2.js"></script>
<script src="http://code.jquery.com/ui/1.9.1/jquery-ui.js"></script>
<link rel="stylesheet" href="/resources/demos/style.css" />
<style>
#feedback { font-size: 1.4em; }
#selectable .ui-selecting { background: #FECA40; }
#selectable .ui-selected { background: #F39814; color: white; }
#selectable { list-style-type: none; margin: 0; padding: 0; width: 60%; }
#selectable li { margin: 3px; padding: 0.4em; font-size: 1.4em; height: 18px; }
</style>
<script>
$(function() {
$("#selectable").selectable({
stop: function() {
var result = $("#select-result").empty();
var tag_names = []
$(".ui-selected", this).each(function() {
var item = this.innerHTML;
result.append((item));
tag_names.push(item)
});
}
});
});
</script>
</head>
<body>
<p id="feedback">
<span>Tags:</span> <span id="select-result">none</span>.
</p>
<ol id="selectable">
<%@tags.each_key do |tag| %>
<li class="ui-widget-content"> #<%=tag%> </li>
<%end%>
</ol>
如果你覺得我的回答是有用的,請給予好評,並接受它。 –