javascript - how to upload file through activeadmin modal window -


i want upload file using modal window,but activeadmin modal module doesn't support .

so changed source file of activeadmin, actualy /app/assets/javascripts/active_admin/lib/modal_dialog.js.coffee

activeadmin.modal_dialog = (message, inputs, callback)->   html = """<form id="dialog_confirm" title="#{message}"><ul>"""   name, type of inputs     if /^(datepicker|checkbox|text)$/.test type       wrapper = 'input'     else if type 'textarea'       wrapper = 'textarea'     else if $.isarray type       [wrapper, elem, opts, type] = ['select', 'option', type, '']     else       throw new error "unsupported input type: {#{name}: #{type}}" 

i add change code if /^(datepicker|checkbox|text)$/.test type

if /^(datepicker|checkbox|text|file)$/.test type 

then can show file form, can't params ,can 1 help?

here's code:

$('a.upload').click (event) ->     event.preventdefault()     activeadmin.modal_dialog "send file", choose_file: "file",       (inputs)=>          if inputs.choose_file == ""           alert "!!!"         else           $.post $(@).attr("href"),             {               choose_file: inputs.choose_file             }, (data) ->               window.location.reload() 

the form need's encoded multipart:

html = """<form id="dialog_confirm" title="#{message}" enctype="multipart/form-data"><ul>""" 

Comments

Popular posts from this blog

html - Firefox flex bug applied to buttons? -

html - Missing border-right in select on Firefox -

python - build a suggestions list using fuzzywuzzy -