Jquery 在Ruby on Rails模型中定义的xy位置显示对象
我正在尝试从RubyonRails中的模型中提取x和y位置,并用HTML5表示它。这个位置已经通过jquery拖放捕获,但是我找不到关于如何继续的任何信息 让它更清楚。 我设置了一个x位置和一个y位置变量。 我需要在方法中保存的位置的页面上放置一个可交互的图像 谢谢,如果有更清楚的方法,请随时告诉我 编辑:: 这是RoR最新的表格模型控制器Jquery 在Ruby on Rails模型中定义的xy位置显示对象,jquery,ruby-on-rails,html,css,Jquery,Ruby On Rails,Html,Css,我正在尝试从RubyonRails中的模型中提取x和y位置,并用HTML5表示它。这个位置已经通过jquery拖放捕获,但是我找不到关于如何继续的任何信息 让它更清楚。 我设置了一个x位置和一个y位置变量。 我需要在方法中保存的位置的页面上放置一个可交互的图像 谢谢,如果有更清楚的方法,请随时告诉我 编辑:: 这是RoR最新的表格模型控制器 class TablesController < ApplicationController before_action :set_table,
class TablesController < ApplicationController
before_action :set_table, only: [:show, :edit, :update, :destroy]
skip_before_filter :verify_authenticity_token
# GET /tables
# GET /tables.json
def index
@tables = Table.all
end
# GET /tables/1
# GET /tables/1.json
def show
end
# GET /tables/new
def new
@table = Table.new
end
# GET /tables/1/edit
def edit
end
# POST /tables
# POST /tables.json
def create
@table = Table.new(table_params)
respond_to do |format|
if @table.save
format.html { redirect_to @table, notice: 'Table was successfully
created.' }
format.json { render :show, status: :created, location: @table }
format.js {render :json => @table}
else
format.html { render :new }
format.json { render json: @table.errors, status: :unprocessable_entity
}
format.js {render :json =>@table.errors, status: :unprocessable_entity}
end
end
end
# PATCH/PUT /tables/1
# PATCH/PUT /tables/1.json
def update
respond_to do |format|
if @table.update(table_params)
format.html { redirect_to @table, notice: 'Table was successfully
updated.' }
format.json { render :show, status: :ok, location: @table }
else
format.html { render :edit }
format.json { render json: @table.errors, status: :unprocessable_entity }
end
end
end
# DELETE /tables/1
# DELETE /tables/1.json
def destroy
@table.destroy
respond_to do |format|
format.html { redirect_to tables_url, notice: 'Table was successfully
destroyed.' }
format.json { head :no_content }
end
end
private
# Use callbacks to share common setup or constraints between actions.
def set_table
@table = Table.find(params[:id])
end
def table_params
params.permit(:num_seats, :restaurant_id, :x_loc, :y_loc, :available)
end
end
编辑2::
我已经尝试过使用变量进行建议的内嵌css样式,以及使用javascript制作HTML5画布。css样式是在每个do循环中为每个迭代提取图像的唯一样式,但它没有正确定位
我有调试语句显示它正在获取信息
<script>document.write("<%=table.x_loc%>")</script>
但是,提供了正确的信息
>
没有正确定位图像。您能告诉我们您到目前为止做了什么吗?我添加了控制器代码,因为我认为这是显示我所追求的最好的东西,桌子模型由餐厅老板随意放置,每次都创建一个新模型,并保存x和y。然后,我希望新视图上的客户能够看到餐厅,看到每张桌子所在的图像,然后希望能够单击该图像进行交互式下拉。显示的包含元素的尺寸是否与原始拖放所用的尺寸相同?容器是否设置为位置:相对?您是否设置为位置:绝对?