这是我的代码:
<%= f.select :area, options_for_select([['a','a'],['b','b'],['c','c']]), {}, {:class => 'span3 controls controls-row'}, :selected => params[:area] %>
Run Code Online (Sandbox Code Playgroud)
结果是:
ArgumentError in Users#edit
Showing /home/airson/rails_projects/friends_of_local/app/views/users/edit.html.erb where line #17 raised:
wrong number of arguments (5 for 4)
Run Code Online (Sandbox Code Playgroud)
为什么.....@@?
作为讨论的基础.创建一个标准的ASP.NET MVC Web项目.
它将在母版页中包含两个菜单项:
<div id="menucontainer">
<ul id="menu">
<li>
<%= Html.ActionLink("Home", "Index", "Home")%></li>
<li>
<%= Html.ActionLink("About", "About", "Home")%></li>
</ul>
</div>
Run Code Online (Sandbox Code Playgroud)
如何设置指示当前页面的可视CSS样式.例如,在About页面/控制器中,我基本上想要这样做:
<%= Html.ActionLink("About", "About", "Home", new {class="current"})%></li>
Run Code Online (Sandbox Code Playgroud)
当然,当在主页上时:
<%= Html.ActionLink("Home", "Index", "Home", new {class="current"})%></li>
Run Code Online (Sandbox Code Playgroud)
(CSS样式名称当前在菜单中可视地指示这是当前页面.)
我可以将菜单div从主页面分成内容占位符,但这意味着我必须将菜单放在每个页面上.
任何想法,有一个很好的解决方案吗?
<html>
<body>
<script type="text/javascript">
function smth() {
if (document.getSelection) {
var str = document.getSelection();
if (window.RegExp) {
var regstr = unescape("%20%20%20%20%20");
var regexp = new RegExp(regstr, "g");
str = str.replace(regexp, "");
}
} else if (document.selection && document.selection.createRange) {
var range = document.selection.createRange();
var str = range.text;
}
alert(str);
}
</script>
<iframe id="my" width="300" height="225">
.....some html ....
</iframe>
<a href="#" onclick="smth();">AA</a>
</body>
</html>
Run Code Online (Sandbox Code Playgroud)
有smth功能我可以从一些div中获取所选文本,但它不适用于iframe.任何想法如何从iframe中获取所选文本?
我完全改变了这个问题,因为它的一部分在 Avnish的帮助下得到了回答!汤姆把我送到了正确的方向,谢谢汤姆!
我的问题是我不知道如何告诉Thymeleaf在编辑时预先选择对象元素.
让我演示给你看:

此解决方案有效:
<select class="form-control" id="parts" name="parts" multiple="multiple">
<option th:each="part : ${partsAtribute}"
th:selected="${servisAttribute.parts.contains(part)}"
th:value="${part.id}"
th:text="${part.name}">Part name</option>
</select>
Run Code Online (Sandbox Code Playgroud)
我试过这个:
<select class="form-control" th:field="*{parts}" multiple="multiple">
<option th:each="part : ${partsAtribute}"
th:field="*{parts}"
th:value="${part.id}"
th:text="${part.name}">Part name</option>
</select>
Run Code Online (Sandbox Code Playgroud)
不工作.我也试过这个:
<select class="form-control" th:field="*{{parts}}" multiple="multiple">
<option th:each="part : ${partsAtribute}"
th:field="*{parts}"
th:value="${part.id}"
th:text="${part.name}">Part name</option>
</select>
Run Code Online (Sandbox Code Playgroud)
也没用.我试过th:field="*{parts}"从选项标签中删除,结果相同..
如果我改变th:value到${part}它的工作原理,但随后它并没有发回的ID字符串如[2,4,5,6,...],但Part像实例[第@ 43b45j,部分@ we43y7,...] ... .
更新:我刚刚注意到,如果只选择了一个部分,这是有效的:
<select class="form-control" th:field="*{parts}" multiple="multiple">
<option th:each="part : ${partsAtribute}"
th:field="*{parts}"
th:value="${part.id}"
th:text="${part.name}">Part name</option>
</select>
Run Code Online (Sandbox Code Playgroud)
如果选择了多个部件,则不起作用......
我试图使用Swift更改自定义选定的TableViewCell的外观.
我需要通过设计师还是以编程方式完成?
我尝试了以下方法:
这是我的代码:
@IBOutlet var tableView: UITableView!
var tableData: [String] = ["One", "Two", "Three", "Four"]
override func viewDidLoad() {
super.viewDidLoad()
// Register custom cell
var nib = UINib(nibName: "vwTblCell", bundle: nil)
tableView.registerNib(nib, forCellReuseIdentifier: "cell")
}
func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return self.tableData.count
}
func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
var cell:TblCell = self.tableView.dequeueReusableCellWithIdentifier("cell") as TblCell
cell.lblCarName.text = tableData[indexPath.row]
cell.imgCarName.image = UIImage(named: tableData[indexPath.row])
return cell
}
func tableView(tableView: UITableView!, didSelectRowAtIndexPath indexPath: NSIndexPath!) { …Run Code Online (Sandbox Code Playgroud) 我有一个DOM元素的引用,以及一个jQuery对象,它是一个选择器的结果,我想检查该特定的DOM元素是否在该jQuery对象中.如果没有循环遍历整个jQuery对象并检查是否相等,那么jQuery中有一种直接的方法可以做到这一点吗?
我已经试过.contains,:contains,.has和:has,和他们都不做的工作.另外,我应该提到我正在使用的所有元素都在相同的DOM树级别上,所以不必担心父母/孩子.
我是一个Android新手,试图学习UI方面的东西,它正在努力.这就是我现在所拥有的:
breeds_listing.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content" android:layout_height="wrap_content">
<ListView android:id="@+id/breedsListView"
android:layout_width="fill_parent" android:layout_height="fill_parent"
android:dividerHeight="0px" android:divider="#00000000"></ListView>
</LinearLayout>
Run Code Online (Sandbox Code Playgroud)
breeds_listing_item.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content" android:layout_height="wrap_content"
android:background="@drawable/list_item_background"
android:orientation="horizontal" >
<TextView android:id="@+id/allbreeds_single_item"
android:layout_width="fill_parent" android:layout_height="fill_parent"
android:gravity="center_horizontal"></TextView>
</LinearLayout>
Run Code Online (Sandbox Code Playgroud)
list_item_background.xml
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<solid android:color="#043402" />
<stroke android:width="3dp" color="#ffff8080" />
<corners android:radius="8dp" />
<padding android:left="10dp" android:top="10dp" android:right="10dp"
android:bottom="10dp" />
</shape>
Run Code Online (Sandbox Code Playgroud)
我正在努力弄清楚的是我如何设计所选项目的样式?目前,所选项目具有可怕的橙色背景,在圆形绿色矩形下,呈现橙色轮廓效果.我确信我没有按照最佳做法做事,所以任何建议或改进都将不胜感激.
非常感谢,D.
我需要在弹出列表中更改ComboBox所选项目的突出显示颜色.我找到了几个教程解释如何做到这一点,但他们都使用Blend,我没有和无法获得,或涉及更改系统默认颜色 - 这似乎是我的黑客.
有人能指出我需要覆盖的模板,还是告诉我需要设置的属性?
我使用MVVM,并使用一些代码将datagrid绑定到集合:
<DataGrid ItemsSource="{Binding Entites}" AutoGenerateColumns="False" IsSynchronizedWithCurrentItem="True"
SelectedItem="{Binding SelectedEntity}">
Run Code Online (Sandbox Code Playgroud)
我也使用样式(RowStyle或ItemContainerStyle)使用绑定到IsSelectedProperty
<DataGrid.RowStyle>
<Style>
<Setter Property="DataGridRow.IsSelected" Value="{Binding IsSelectedProperty, Mode=TwoWay}" />
</Style>
</DataGrid.RowStyle>
Run Code Online (Sandbox Code Playgroud)
它运作良好.但是如果我向下和向上滚动数据网格,它就会停止工作.
我想查看所选的无线电输入是什么.
这是我的代码.
<input name="u_type" type="radio" value="staff" id="u_type" checked="checked" /> Staff
<input name="u_type" type="radio" value="admin" id="u_type" /> Admin
<input id="add_user" name="add_user" type="button" onclick="addUser();" value="Add" class="submitButton admin_add" />
function addUser()
{
//how to check what is the selected radio input
}
Run Code Online (Sandbox Code Playgroud)
谢谢.