Forum closed. New forum available at http://community.wymeditor.org/

AJAX: manually calling wym.update()

Support forum for WYMeditor.

AJAX: manually calling wym.update()

Postby karlmdavis on Sun Sep 23, 2007 6:50 pm

Hello all,

I'm trying to integrate WYMeditor with an Ajax-using application and am having trouble with getting access to the update() method. I have a button that performs an Ajax submit and also has "wymupdate" as its class, but unfortunately the submit code seems to be processed before the wymupdate code.

I have tried adding the following Javascript before my Ajax submit, but it seems to not work:
Code: Select all
for(wym in WYM_INSTANCES) { wym.update(); }

In Venkman, I see it throw an "wym.update is not a function" error.

Due to the framework I'm using, I'm unable to manipulate my Ajax submit code, other than specifying Javascript to be run before or after it. Any ideas how I can fix this problem?

Thanks!
Karl
karlmdavis
 
Posts: 3
Joined: Sun Sep 23, 2007 6:41 pm

Solved!

Postby karlmdavis on Mon Sep 24, 2007 12:10 am

Well, I guess I'm lacking in my knowledge of Javascript. I still have no idea why the above code doesn't work, but the following does:
Code: Select all
for(i=0;i<WYM_INSTANCES.length;i++) { WYM_INSTANCES[i].update(); };


Hope this helps someone out!
karlmdavis
 
Posts: 3
Joined: Sun Sep 23, 2007 6:41 pm

Postby jfh on Wed Sep 26, 2007 12:09 pm

Actually this is the safest way to enumerate an array in JS.
User avatar
jfh
Site Admin
 
Posts: 370
Joined: Sat Sep 23, 2006 8:43 pm
Location: Belgium

Postby rtomlinson on Mon Oct 22, 2007 9:50 pm

Hi,

When I use this code, it will update the first instance, and then outright end the loop, not updating any of the other instances.

If I try to iterate backwards through the WYM_INSTANCES array like so:

Code: Select all
for(i=WYM_INSTANCES.length - 1; i >= 0; i--)  { WYM_INSTANCES[i].update(); };


it tells me that WYM_INSTANCES[i] has no properties on the first time through the loop.

I've got a test page here. You can see this issue by clicking the "Update test" button at the bottom of the page.

Note that I have another issue as well that is unrelated to this particular issue. I'll post that in another thread that is relevant.

Thanks, I really hope to get this working, this looks like the best editor out there.
rtomlinson
 
Posts: 4
Joined: Fri Oct 19, 2007 11:33 pm

Postby rtomlinson on Mon Oct 22, 2007 10:15 pm

I have this history of agonizing over things for days, finally posting a question to a forum, and then figuring it out shortly thereafter.

I didn't explicitly declare the "i" variable, so somewhere in the update function it was getting it confused with its own "i" variable. Declaring it solved the updating problem.
rtomlinson
 
Posts: 4
Joined: Fri Oct 19, 2007 11:33 pm


Return to Support

Who is online

Users browsing this forum: No registered users and 2 guests