我有一个列出项目的页面.在每个项目下面,它列出了该项目的任何注释(注释是项目下的嵌套资源).
您可以在项目页面上添加新注释.当你这样做时,它正在重新加载整个页面,所以我想改变它以使用Ajax并只使用jQuery插入注释.
所以我将注释/ _form.html.erb改为使用:remote => true
<%= form_for([@item,@comment], :remote=>true) do |f| %>
Run Code Online (Sandbox Code Playgroud)
我在comments_controller中添加了一个format.js:
def create
@comment = Comment.new(params[:comment])
@comment.save
respond_to do |format|
format.js
format.html { redirect_to items_path}
end
end
Run Code Online (Sandbox Code Playgroud)
并创建了一个简单的注释/ create.js.erb来将新注释插入页面:
$("#comments").append("<%= j(render(@comment)) %>");
Run Code Online (Sandbox Code Playgroud)
但是,当我提交注释时(即使表单上有:remote => true),它会不断重新加载整个页面/忽略我的.js文件.
所以我从respond_to中删除了format.html(因为我不想使用该选项),但是它给了我4ms内完成406不可接受的错误(ActiveRecord:0.2ms)
如何让它留在当前页面并使用我的create.js回复?
我已将DataContext设置为Book对象.书有属性:标题,类别.
我有一个CollectionViewSource"categoryList",它包含一个Categories列表.
问题:如何在此组合框中选择书籍的类别?
<TextBox Text="{Binding Path=Title}"/>
<ComboBox SelectedValuePath="Id"
SelectedValue="{Binding Path=Category.Id}"
SelectedItem="{Binding Path=Category}"
ItemsSource="{Binding Source = {StaticResource categoryList}}"
DisplayMemberPath="Name" />
Run Code Online (Sandbox Code Playgroud)
上面的代码正确显示了书的标题,然后它显示了组合框中的类别名称列表.但它没有选择书的类别.它只是选择列表中的第一项.
我在cygwin下使用git但它没有将正确的路径传递给我的编辑器以提交消息.
我在位于我的驱动器上的测试存储库中工作:
d:\X\git\myproject
Run Code Online (Sandbox Code Playgroud)
在cygwin终端中,它将此路径显示为:
/cygdrive/d/X/git/myproject
Run Code Online (Sandbox Code Playgroud)
当我在没有-m标志的情况下提交(以便它打开我的编辑器让我输入消息)时,我的编辑器会尝试将文件写入错误的路径:
d:\cygdrive\d\x\git\myproject\.git\commit_editmsg
Run Code Online (Sandbox Code Playgroud)
注意添加"\ cygdrive\d"
如何让git将windows路径(而不是cygwin/unix路径)传递给我的编辑器?