Skip to content

Commit e8eb5b5

Browse files
committed
Ensure that page parts get appended inside the correct element and clean up the dialog after closing it. Closes refineryGH-477
1 parent 57f222c commit e8eb5b5

File tree

1 file changed

+7
-7
lines changed
  • core/public/javascripts/refinery

1 file changed

+7
-7
lines changed

core/public/javascripts/refinery/admin.js

+7-7
Original file line numberDiff line numberDiff line change
@@ -676,34 +676,34 @@ var page_options = {
676676
var tab_title = part_title.toLowerCase().replace(" ", "_");
677677

678678
if ($('#part_' + tab_title).size() === 0) {
679-
$.get(page_options.new_part_url,
680-
{
679+
$.get(page_options.new_part_url, {
681680
title: part_title
682681
, part_index: $('#new_page_part_index').val()
683682
, body: ''
684-
}
685-
, function(data, status){
683+
}, function(data, status){
686684
$('#submit_continue_button').remove();
687685
// Add a new tab for the new content section.
688686
$(data).appendTo('#page_part_editors');
689687
page_options.tabs.tabs('add', '#page_part_new_' + $('#new_page_part_index').val(), part_title);
690688
page_options.tabs.tabs('select', $('#new_page_part_index').val());
691689

692-
// turn the new textarea into a wymeditor.
693-
$('#page_parts_attributes_' + $('#new_page_part_index').val() + "_body").wymeditor(wymeditor_boot_options);
694-
695690
// hook into wymedtior to instruct it to select this new tab again once it has loaded.
696691
WYMeditor.onload_functions.push(function() {
692+
$('#page_part_new_' + $('#new_page_part_index').val()).appendTo('#page_part_editors');
697693
page_options.tabs.tabs('select', $('#new_page_part_index').val());
698694
});
699695

696+
// turn the new textarea into a wymeditor.
697+
WYMeditor.init();
698+
700699
// Wipe the title and increment the index counter by one.
701700
$('#new_page_part_index').val(parseInt($('#new_page_part_index').val(), 10) + 1);
702701
$('#new_page_part_title').val('');
703702

704703
page_options.tabs.find('> ul li a').corner('top 5px');
705704

706705
$('#new_page_part_dialog').dialog('close');
706+
$('#new_page_part_dialog').remove();
707707
}
708708
);
709709
}else{

0 commit comments

Comments
 (0)