我正在尝试使用带有'bootstrap-editable-rails'的type = select。
该字段会弹出,并且有一个选择框,但这些值不会显示。
任务记录有一个外键= rating_id,我想从评级表中显示的值是= ratingname
这是我的观看代码:
<a href="#" class="answer" data-type="select" data-placement="right" data-resource="task" data-source="/ratings" data-name="ratingname" data-url="/tasks/<%= task.id %>" data-original-title="Select Rating">
<%= textarea_format(task.rating.ratingname) %>
</a>
更新1
我是否必须更改ratings.json以包含“text”和“value”?
更新2
我像这样使用RABL:
object @rating
attributes :id => :id, :ratingname => :text, :ratingvalue => :value
现在选择值显示出来了!
但是,我收到了这个错误:
`call'
(gem) journey-1.0.4/lib/journey/router.rb:68:in `block in call'
- (gem) journey-1.0.4/lib/journey/router.rb:56:in `call'
- (gem) actionpack-3.2.12/lib/action_dispatch/routing/route_set.rb:601:in `call'
- (gem) rack-pjax-0.7.0/lib/rack/pjax.rb:12:in `call'
- (gem) meta_request-0.2.2/lib/meta_request/middlewares/app_request_handler.rb:11:in `call'
- (gem) rack-contrib-1.1.0/lib/rack/contrib/response_headers.rb:17:in `call'
- (gem) meta_request-0.2.2/lib/meta_request/middlewares/headers.rb:16:in `call'
- (gem) meta_request-0.2.2/lib/meta_request/middlewares/meta_request_handler.rb:13:in `call'
- (gem) pdfkit-0.5.3/lib/pdfkit/middleware.rb:16:in `call'
- (gem) warden-1.2.1/lib/warden/manager.rb:35:in `block in call'
- (gem) warden-1.2.1/lib/warden/manager.rb:34:in `call'
- (gem) actionpack-3.2.12/lib/action_dispatch/middleware/best_standards_support.rb:17:in `call'
- (gem) rack-1.4.5/lib/rack/etag.rb:23:in `call'
- (gem) rack-1.4.5/lib/rack/conditionalget.rb:35:in `call'
- (gem) actionpack-3.2.12/lib/action_dispatch/middleware/head.rb:14:in `call'
- (gem) remotipart-1.0.5/lib/remotipart/middleware.rb:30:in `call'
- (gem) actionpack-3.2.12/lib/action_dispatch/middleware/params_parser.rb:21:in `call'
- (gem) actionpack-3.2.12/lib/action_dispatch/middleware/flash.rb:242:in `call'
- (gem) rack-1.4.5/lib/rack/session/abstract/id.rb:210:in `context'
- (gem) rack-1.4.5/lib/rack/session/abstract/id.rb:205:in `call'
- (gem) actionpack-3.2.12/lib/action_dispatch/middleware/cookies.rb:341:in `call'
- (gem) activerecord-3.2.12/lib/active_record/query_cache.rb:64:in `call'
...
更新3
我差不多了。
我的RABL:
object @rating
attributes :ratingname => :text, :id => :value
我将ratingname作为下拉列表! 选择值时会发生以下情况!!
UPDATE "tasks" SET "rating_id" = 2, "updated_at" = '2013-03-28 08:21:36.869872' WHERE "tasks"."id" = 36
因此,下拉列表很好,更新很好。
但是,带有评级选择列表的弹出框变为红色并且不会消失!并且浏览器控制台中没有错误。
答案 0 :(得分:0)
让它发挥作用。我不得不在更新部分更改控制器以执行任务。
From: format.json { head :ok }
To: format.json { render json: @task }
答案 1 :(得分:-1)
有时你可能会遇到js冲突,所以检查控制台
未捕获的TypeError:无法使用'in'运算符在undefined中搜索'value'
解决方案:将其内联使用
$。fn.editable.defaults.mode ='inline';