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

Calling a function from postInitDialog

Support forum for WYMeditor.

Calling a function from postInitDialog

Postby shacker on Wed Mar 11, 2009 1:19 am

This may sound like a Django question, but it's really a wyme/javascript question :)

I'm following the instructions for integration of WYME into Django here http://trac.wymeditor.org/trac/wiki/Contrib/IntegrateInDjango .

Everything goes fine with simple integration, using:

Code: Select all
$('textarea').wymeditor({
    postInitDialog: wymeditor_filebrowser
  });


However, the instructions say:

If you already have a postInitDialog function, you need to put a call to wymeditor_filebrowser inside that function.


I do need a postInitDialog (for other reasons). However, if I call wymeditor_filebrowser from within postInitDialog as instructed at the URL above, it never gets called. I'm not sure exactly where in the function to put it. Here's what I've got (not working):


Code: Select all
         //handle click event on dialog's submit button
         postInitDialog: function( wym, wdw ) {
         
             //wdw is the dialog's window
             //wym is the WYMeditor instance
         
             var body = wdw.document.body;
             wymeditor_filebrowser();
         
             jQuery( body )
                 .find('input.wym_submit_wrap')
                 .click(function() {
         
                     var tag   = jQuery(body).find('.wym_select_inline_element').val();
                     var title = jQuery(body).find('.wym_title').val();
         
                     wym.wrap( '<' + tag + ' title="' + title + '">', '</' + tag + '>' );
                     wdw.close();
         
                 });
         },
       


So -- when wymeditor_filebrowser is called from outside of postInitDialog, it works fine. When it's called from within postInitDialog, it's ignored. Can someone clue me in on exactly how to call it?

Thanks,
Scot
shacker
 
Posts: 9
Joined: Thu Mar 05, 2009 7:30 pm

Re: Calling a function from postInitDialog

Postby mr_lundis on Wed Mar 11, 2009 1:09 pm

Hi Scot, and welcome to the WYMEditor forum!

You'll need to pass along the callback arguments, otherwise the function wont execute properly. Just change wymeditor_filebrowser(); to wymeditor_filebrowser(wym, wdw); and it'll work.

Cheers!;)
Jonatan Lundin - designer, developer and forum moderator. You should follow me on Twitter!
mr_lundis
 
Posts: 335
Joined: Sun Dec 02, 2007 10:59 am
Location: Sweden

Re: Calling a function from postInitDialog

Postby shacker on Wed Mar 11, 2009 5:20 pm

Bingo, works perfectly. Thanks mr_lundis!
shacker
 
Posts: 9
Joined: Thu Mar 05, 2009 7:30 pm

Re: Calling a function from postInitDialog

Postby shacker on Wed Mar 11, 2009 5:26 pm

Hmm, I wanted to add this bit of information into the Django Integration wiki page http://trac.wymeditor.org/trac/wiki/Contrib/IntegrateInDjango . Created an account, logged in, but it still won't let me edit. Would be nice if someone with edit access could make this change.
shacker
 
Posts: 9
Joined: Thu Mar 05, 2009 7:30 pm

Re: Calling a function from postInitDialog

Postby mr_lundis on Wed Mar 11, 2009 6:50 pm

I've updated the wiki page.
Duno why you weren't able to edit the page, I guess Jean-François disabled that functionality for non dev members. (I'll look in to it)

Cheers! ;)
Jonatan Lundin - designer, developer and forum moderator. You should follow me on Twitter!
mr_lundis
 
Posts: 335
Joined: Sun Dec 02, 2007 10:59 am
Location: Sweden

Re: Calling a function from postInitDialog

Postby shacker on Wed Mar 11, 2009 11:33 pm

Most excellent - thanks!
shacker
 
Posts: 9
Joined: Thu Mar 05, 2009 7:30 pm


Return to Support

Who is online

Users browsing this forum: No registered users and 2 guests

cron