I am trying to create a command that writes text to an open
XML file. The command I've created works fine under some
circumstances but not others.
It works if I open an XML file and apply the command without
editing the file. If I make any edits to the file manually and then
apply the command, it doesn't insert anything.
It works fine with HTML files in design view, but in code
view, if I make any edits and then run the command, nothing
happens. If I switch to design view and back again, the command
then works fine.
I tested the built-in Dreamweaver command "Flash Text" on an
XML file (after editing it so it could be used with an XML file),
and the same problem occurs with this command when using it on an
XML file. The problem didn't occur with HTML in code view, though.
Below is the .JS file for my command. The corresponding HTML
file contains only an empty form.
function canAcceptCommand() {
return(true);
}
function isDOMRequired() {
return false;
}
function commandButtons()
{
return new Array( MM.BTN_OK, "cmdOK(); "
, MM.BTN_Cancel, "cmdCancel();");
}
function cmdOK()
{
var theDOM = dw.getDocumentDOM('document');
theDOM.insertHTML("test", true);
window.close();
}
function cmdCancel()
{
window.close();
}