Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Reload current document?

Explorer ,
Jun 12, 2007 Jun 12, 2007
Running DW8, building an insertObject() extension; 2 problems that appear related to loading the current document.

Problem 1:
DW maintains the current document as it was loaded, even after making a change to it and saving; I have to reload the document (manually) for it to be treated properly with extension.

Here's what's going on:
I have a JavaScript function that reads a meta tag content in the current document. Between function calls, I change the meta tag content and save the file. DW still refers to the old content.

Problem 2:
The insertObject() function does not run if the document has unsaved or saved changes.

Here's what's going on:
My insertObject() function inserts a line of text into the current document. It will run the first time on the document, when the document has not been edited. Thereafter, it fails, even if the changes have been saved.

I've tried calling dw.releaseDocument(dom); at the end of each function explicitly, to no avail.

When I run example code from the Extending Dreamweaver reference, it works as expected.

Any ideas?
TOPICS
Extensions
812
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Deleted User
Jun 20, 2007 Jun 20, 2007
If you're changing the metatag in codeview and don't click into design view before you hit your extension, then the dom you get from dw.getDocumentDOM() is out of sync with the code view. We don't sync it automatically since some insert objects can just dump a string into code view (or they can use dom.source which is up to date). In this case, I think you just need to add:
dom.synchronizeDocument();

Also, I saw in our code that we do have a releaseDocument, so you call weren't hurting anything...
Translate
Guest
Jun 13, 2007 Jun 13, 2007
For Problem 1, how are you adding and saving the file. If you're acting on the the dom object directly DW should update correctly. If you do string manipulations and use DWFile to save it, then we may not notice the file on disk has changed yet.

For Problems 2, can you open another document and have your extension work. That is, does your application work correctly twice during the application session? You can also check the handlers you added to the insertbar.xml and make sure they're return true when you want to edit the document.

If you're still having problems, please post some code samples as that will help narrow down the problem.

Hope that helps,
Chris
Adobe Dreamweaver Engineering
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Jun 13, 2007 Jun 13, 2007
Thanks Chris, for the prompt reply!

Running the extension on currentDoc1, then opening a second currentDoc2 works with the same limitations described
below. So, "does your application work correctly twice during the application session?" Yes.

Also, an update to problem 2:
Although the initial run of the extension inserts the text correctly, if you enter a Return and attempt to repeat the insertion on the next line, no insertion takes place, the function fails. Otherwise, if you continue running the function on the same line, it keeps working, regardless of whether you save the document or not.

To revisit problem 1:
If you open the currentDoc, change it's SKU_Condition meta tag content and save the currentDoc, the function runs as if the change has not taken place; the dialog displays the SKU_Condition meta tag content that was in the previous version. You have to close the currentDoc, then reopen it, to get the function to read the updated SKU_Condition meta tag. Note, I'm not doing the close/reopen programatically.

I've attached the JavaScript, but I'd like to send a zip file with the whole thing - at the risk of appearing presumptuous. A few code snippets might not help you understand the problem, and you'll have to be able to run the bloody thing. Can you give me an address where I can send you this?

Thanks very much!
-Scott
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Jun 20, 2007 Jun 20, 2007
Sorry, i had a bit of a break. If you're still having problems zip up you files, put them on a website and post a link here. I'll look at the briefly to see what's up. Also, FWIW there is no dw.releaseDocument() so you don't need to call that (in fact you may try and remove that as it's probably causing a runtime error, though that should have been reported to you)

Chris
Adobe Dreamweaver Enginerring
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Jun 20, 2007 Jun 20, 2007
Thanks Chris,

Here you go:

http://www.geocities.com/srowe3/everything_50_percent.html

There's only one file, scott.zip

I really appreciate you're looking into this!

-Scott
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Jun 20, 2007 Jun 20, 2007
Chris,
Here's the web page you requested:
http://www.geocities.com/srowe3/everything_50_percent.html
The file is scott.zip
Thanks for looking into this!
-Scott
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Jun 20, 2007 Jun 20, 2007
If you're changing the metatag in codeview and don't click into design view before you hit your extension, then the dom you get from dw.getDocumentDOM() is out of sync with the code view. We don't sync it automatically since some insert objects can just dump a string into code view (or they can use dom.source which is up to date). In this case, I think you just need to add:
dom.synchronizeDocument();

Also, I saw in our code that we do have a releaseDocument, so you call weren't hurting anything, but they probably weren't doing much either. You'd need to call that if you're getting a lot of DOMs and you want to give us a chance to free them, but we do that on idle anyway so you don't have to worry.

Hope that helps,
Chris
Adobe Dreamweaver Engineering
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Jun 22, 2007 Jun 22, 2007
LATEST
Hallelujah!!!

That's the ticket, Chris!

Thanks!!!!!

-Scott
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines