Created
February 7, 2012 18:58
-
-
Save zerodie/1761244 to your computer and use it in GitHub Desktop.
new app
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<%= simple_form_for([@system, @app], :remote => true) do |f| %> | |
<%= f.input :name, :placeholder=>"AppBook" %> | |
<%#= f.input :price, :as => :float %> | |
<div class="input numeric float required input-append unit"> | |
<label class="float required" for="app_price"><abbr title="required">*</abbr> 價格</label> | |
<input class="numeric float required" id="app_price" name="app[price]" required="required" step="any" type="number" placeholder="0.99" /><span class="add-on">美金</span> | |
</div> | |
<%= f.input :size, :placeholder=>"20 M" %> | |
<%= f.input :required_version, :placeholder=>"2.1 以上" %> | |
<%#= f.association :category, :collection => @categories, :label => "分類" %> | |
<div class="input select required app_sellabe_type company" id="app_sellabe_type"> | |
<label class="select required" for="app_sellable_type"><abbr title="required">*</abbr>開發商</label></label> | |
<select class="required" name="app[sellable_type]" id="identity" required="required"> | |
<option value="" selected="selected">請選擇開發商型別</option> | |
<option value="Company">公司</option> | |
<option value="Developer">獨立開發者</option> | |
</select> | |
</div> | |
<div class="input select required company" id="app_selable_id shi"> | |
<select class="required" id="app_sellable_id" name="app[sellable_id]" required="required"> | |
<option>請選擇名稱</option> | |
</select> | |
</div> | |
<% if @system.name == "Windows" %> | |
<%= f.input :xboxlive, :as => :boolean %> | |
<% end %> | |
<div class="input select required"> | |
<label class="select required" for="app_category_id"><abbr title="required">*</abbr> 分類</label> | |
<select class="select required" id="app_category_id" name="app[category_id]"> | |
<%= grouped_options_for_select(@system.categories_group,nil,nil) %> | |
</select> | |
</div> | |
<div class="input pics"> | |
<%= f.label :logo %><%= f.file_field :logo %> | |
</div> | |
<div class="input pics"> | |
<%= f.label "螢幕截圖" %> | |
<%= f.simple_fields_for :pictures do |shot_form| %> | |
<%= shot_form.file_field :file, :name => "app[pictures_attributes][0][file]", :id => "app_pictures_attributes_0_file" %> | |
<%= shot_form.file_field :file, :name => "app[pictures_attributes][1][file]", :id => "app_pictures_attributes_1_file" %> | |
<%= shot_form.file_field :file, :name => "app[pictures_attributes][2][file]", :id => "app_pictures_attributes_2_file" %> | |
<% end %> | |
</div> | |
<%= f.input :download_link, :as => :url, :placeholder=>"AppBook.com.tw", :wrapper_html=>{:class=>"download"} %> | |
<%= f.input :desc, :as => :text %> | |
<%= f.input :system_id, :as => :hidden %> | |
<%= f.input :user_id, :input_html => { :value => current_user.id }, :as => :hidden %> | |
<%= f.button :submit, :class=>"btn" %> | |
<% end %> | |
<%#= observe_field("app_sellabe_type", :frequency => 0.25, :update => "app_selable_id", :url => { :action => :find_sellers }, :with => "'app_sellable_id='+value") %> | |
<p><%= Company.all.to_json(:only => [:id, :name]) %></p> | |
<p><%= Developer.all.to_json(:only => [:id, :name]) %></p> | |
<%= content_for :other_js do %> | |
<script> | |
$(function(){ | |
var oSheng = $("#identity"); | |
var oShi = $("#app_sellable_id"); | |
//oSheng.empty();//清空select下拉框 | |
var dSheng = {head:[ | |
{text:"請選擇身分別",id:"Chia"}, | |
{text:"公司",id:"Company"}, | |
{text:"個人開發商",id:"Developer"} | |
]}; | |
var companies = {head:<%=raw Company.all.to_json(:only => [:id, :name]) %>} | |
var developers = {head:<%=raw Developer.all.to_json(:only => [:id, :name]) %>} | |
oSheng.change(function(){//添加onchange事件 | |
oShi.empty();//清空下级下拉框 | |
$("<option value=''>請選擇名稱</option>").appendTo(oShi) | |
if (oSheng.val() == "Company"){ | |
for(i = 0 ; i < companies.head.length ; i++){ | |
//alert("Company"); | |
$("<option value='" + companies.head[i].id + "'>" + companies.head[i].name + "</option>").appendTo(oShi) | |
} | |
} | |
else if (oSheng.val() == "Developer"){ | |
for(i = 0 ; i < developers.head.length ; i++){ | |
$("<option value='" + developers.head[i].id + "'>" + developers.head[i].name + "</option>").appendTo(oShi) | |
} | |
} | |
}); | |
}); | |
//{head:[ | |
// {name:"Polydice",id:"1",parentid:"Company"}, | |
// {name:"Passionbean123",id:"2",parentid:"Company"}, | |
// ]}; | |
</script> | |
<% end %> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment