I'm trying to add inline editing capability to my template. I ajax in content, by referencing the current page with a custom action. Near the beginning of the template code, I do this:
if ($inlineedit) {
$ACT = 'edit';
tpl_content(false);
return;
}
[/color]
At that point, I got an editor without a toolbar, and with a few more things messed up. So l looked through the code, and found that the editor depends on several files initializing it in global scope. So I copied all of that global code:
dw_editor.init();
dw_locktimer.init();
// From edit.js
var $editform = jQuery('#dw__editform');
if ($editform.length == 0) {
return;
}
var $edit_text = jQuery('#wiki__text');
if ($edit_text.length > 0) {
if($edit_text.attr('readOnly')) {
return;
}
// set focus and place cursor at the start
var sel = DWgetSelection($edit_text[0]);
sel.start = 0;
sel.end = 0;
DWsetSelection(sel);
$edit_text.focus();
}
var checkfunc = function() {
textChanged = true; //global var
summaryCheck();
};
$editform.change(checkfunc);
$editform.keydown(checkfunc);
window.onbeforeunload = function(){
if(window.textChanged) {
return LANG.notsavedyet;
}
};
window.onunload = deleteDraft;
// reset change memory var on submit
jQuery('#edbtn__save').click(
function() {
window.onbeforeunload = '';
textChanged = false;
}
);
jQuery('#edbtn__preview').click(
function() {
window.onbeforeunload = '';
textChanged = false;
window.keepDraft = true; // needed to keep draft on page unload
}
);
var $summary = jQuery('#edit__summary');
$summary.change(summaryCheck);
$summary.keyup(summaryCheck);
if (textChanged) summaryCheck();
// From toolbar.js
initToolbar('tool__bar','wiki__text',toolbar);
jQuery('#tool__bar').attr('role', 'toolbar');
[/color]
Now I have a toolbar, but there's no text in the textarea. Any ideas on how to take that last step, or how to debug this?