尝试使用 Best In Place 从索引中更新记录 [英] Trying to update a record from within an Index using Best In Place

查看:50
本文介绍了尝试使用 Best In Place 从索引中更新记录的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用单独的 jQuery 或就地编辑器Best In Place"更新索引中的记录.没有在我的 行上获得复选框并丢失格式.我使用 this rails cast 作为指南,但是当我在Ryan 使用的复选框,我收到一条错误消息:

I am trying to update a record from an index using either jQuery alone or the in-place editor "Best In Place". Not getting the checkbox and losing formatting on my <THEAD> row. I was using this rails cast as a guide but when I used the syntax on the checkbox Ryan used I got an error saying:

更新:Ruby 1.8.7

Update: Ruby 1.8.7

语法错误,意外的':',需要')'

syntax error, unexpected ':', expecting ')'

代码--

Application.js:

Application.js:

//= require jquery
//= require jquery_ujs
//= require_tree .
//= require jquery.tablednd_0_5.js
//= require jquery.tablesorter.js
//= require jquery.purr
//= require best_in_place

评论、crb_agenda 和 pre_release_agenda 咖啡脚本:

comments, crb_agenda and pre_release_agenda coffee scripts:

jQuery ->
  $('.best_in_place').best_in_place()

comments_controller.rb#update

comments_controller.rb#update

  def update
    @comment = Comment.find(params[:id])

    respond_to do |format|
      if @comment.update_attributes(params[:comment])
        Comment.add_comment_to_jira_ticket("MCTEST-293",@comment.user_comments)
        format.html { redirect_to @comment, :notice => 'Comment was successfully updated.' }
        format.json { head :ok }
      else
        format.html { render :action => "edit" }
        format.json { render :json => @comment.errors, :status => :unprocessable_entity }
      end
    end

CRB Agenda index.html.erb 到 td 与 best_in_place 助手(是的,它是一团糟)

CRB Agenda index.html.erb up to the td with the best_in_place helper (and yes it is a mess)

<table id="main_agenda" class="agenda_table">
        <thead>
          <tr>
            <th></th>
            <th></th>
            <th>Hide?</th>
            <th>Comments</th>
            <th title="Sub tasks due in the next three days">Sub-tasks</th>
            <th>Project name</th>
            <th>Change element</th>
            <th>Issue type</th>
            <th>Key</th>
            <th>Issue links</th>
            <th>Summary</th>
            <th>Assignee</th>
            <th>Reporter</th>
            <th>Dev Lead / Resource Mgr.</th>
            <th>Planned Rel. Dt</th>
            <th>Due Dt</th>
            <th>Approval Source</th>
            <th>SOX</th>
            <th>Dev</th>
            <th>QA</th>
            <th>SQE</th>
            <th>ST</th>
            <th>UX</th>
            <th>App QA</th>
            <th>Systest QA</th>
            <th>SQE Test</th>
            <th>Dependencies</th>
            <th></th>
            <th></th>
          </tr>
        </thead>
        <tbody>
            <% @crb_agendas.each do |crb_agenda| %>
              <% @sub_tasks = [] %>
              <% @linked_issues = SubTask.where(:pdms_key => crb_agenda.key).all %>
              <% @pdms_comment = Comment.where(:jira_key => crb_agenda.key).order("updated_at DESC").first %>
              <tr class="<%= cycle('a_row','b_row') %>" id="<%= crb_agenda.id %>">
                <% SubTask.select("`key`").where(:pdms_key => crb_agenda.key).where("`key` LIKE 'CR%'").where("due_date <= '#{@date_cutoff.to_s}'").each do |sub_key| @sub_tasks << sub_key.key end %>
                <td class="mincell" title="This PDMS has an upcoming iCR on the Pre-Release Agenda"><%= if (@sub_tasks & @icr_key_list).any? == true then "*" end %></td>
                <td><%= best_in_place @pdms_comment, :do_not_show, :type => :check_box, :collection => %w[No Yes] %></td>

  end

这是否涵盖所有内容?

推荐答案

最终放弃了最佳解决方案并创建了我描述的答案 这里

Wound up abandoning Best in Place and creating the answer I describe here

这篇关于尝试使用 Best In Place 从索引中更新记录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆