How to change modal dialog box title dynamically in rails?
I want to change my modal dialog box title according to the database value. Following is my code to load modal dialog box.
page.replace_html 'show_event', :pa开发者_运维技巧rtial => 'show_event'
page<< "$j ('#show_event_dialog').dialog({
title: '',
modal: true,
width: 500,
close: function(event, ui) { $j ('#show_event_dialog').dialog('destroy') }
}); "
I pass event id with link and now I want to change the title as event name. But how can I retrieve database value(event.name) into this js.rjs file? plz can anybody help me?
I dont know rjs well, but every instance variable defined in your controller action should be available to your renderer. try to find your @event in your controller action, and then use string interpolation :
page<< "$j ('#show_event_dialog').dialog({
title: '#{@event.name}',
modal: true,
width: 500,
close: function(event, ui) { $j ('#show_event_dialog').dialog('destroy') }
精彩评论