app/assets/javascripts/active_admin/lib/modal_dialog.js.coffee in activeadmin-1.0.0.pre1 vs app/assets/javascripts/active_admin/lib/modal_dialog.js.coffee in activeadmin-1.0.0.pre2
- old
+ new
@@ -14,21 +14,29 @@
html += """<li>
<label>#{name.charAt(0).toUpperCase() + name.slice(1)}</label>
<#{wrapper} name="#{name}" class="#{klass}" type="#{type}">""" +
(if opts then (
for v in opts
+ $elem = $("<#{elem}/>")
if $.isArray v
- "<#{elem} value=#{v[1]}>#{v[0]}</#{elem}>"
+ $elem.text(v[0]).val(v[1])
else
- "<#{elem}>#{v}</#{elem}>"
+ $elem.text(v)
+ $elem.wrap('<div>').parent().html()
).join '' else '') +
"</#{wrapper}>" +
"</li>"
[wrapper, elem, opts, type, klass] = [] # unset any temporary variables
html += "</ul></form>"
- $(html).appendTo('body').dialog
+
+ form = $(html).appendTo('body')
+ $('body').trigger 'modal_dialog:before_open', [form]
+
+ form.dialog
modal: true
+ open: (event, ui) ->
+ $('body').trigger 'modal_dialog:after_open', [form]
dialogClass: 'active_admin_dialog'
buttons:
OK: ->
callback $(@).serializeObject()
$(@).dialog('close')