Loading ...
Sorry, an error occurred while loading the content.

Re: [ydn-javascript] managing RTE toolbar

Expand Messages
  • Dav Glass
    Try the toolbarLoaded event: myEditor.on( toolbarLoaded , setImageIcon); ... -- Dav Glass davglass@gmail.com blog.davglass.com + Windows: n. - The most
    Message 1 of 4 , Oct 2, 2009
    • 0 Attachment
      Try the toolbarLoaded event:

      myEditor.on('toolbarLoaded', setImageIcon);


      On Fri, 02 Oct 2009, David wrote:

      > Having a little problem. I want to limit the number of images to 1, in a text document. I've written a function ('setImageIcon()') which looks for the presence of a '<img'. If it finds it, it trys to disable the 'insertimage' button.
      >
      > It works fine except when on loading the page. Here's what I've got on loading the window:
      >
      > var myEditor;
      >
      > function initForm(){
      > myEditor = new YAHOO.widget.Editor('story',{
      > width = 'auto',
      > height = '300px,
      > handleSubmit = true
      > });
      >
      > myEditor._defaultToolbar.titlebar = false;
      > myEditor._defaultToolbar.buttonType = 'advanced';
      >
      > myEditor.on('afterRender', setImageIcon());
      > myEditor.render();
      > }
      >
      > function setImageIcon(){
      > ..code..
      > myEditor.toolbar.disableButton('insertimage');
      > }
      >
      > The scripts fails on loading the page telling me that 'myEditor.toolbar is null or does not exist'. I've tried the most logical events to call setImageIcon() but have been unable to find one that does not generate this error.
      >
      > Am I going about this the wrong way or have I overlooked the logical event to make the function call.
      >
      > Thanks,
      > David
      >

      --
      Dav Glass
      davglass@...
      blog.davglass.com


      + Windows: n. - The most successful computer virus, ever. +
      + A computer without a Microsoft operating system is like a dog
      without bricks tied to its head +
      + A Microsoft Certified Systems Engineer is to computing what a
      McDonalds Certified Food Specialist is to fine cuisine +
    • David Fealkoff
      The error went away after I removed the parentheses following setImageIcon, however, it appears that I am still disabling the button too early.  I put an
      Message 2 of 4 , Oct 2, 2009
      • 0 Attachment
        The error went away after I removed the parentheses following setImageIcon, however, it appears that I am still disabling the button too early.  I put an alert after myEditor.disableButton('insertimage') to make sure that the logic was working, which it was, and the alert popped up before the toolbar was fully rendered.  Subsequently when the toolbar rendered the 'insertimage' button was enabled.
         
        I retried the 'afterRender' event and it now gives me the same result as the 'toolbarLoaded' event, that is no error but the call to 'setImageIcon' happens before the toolbar is finally rendered.  Are there any later events that are accessible or ideas on other strategies?
         
        Thanks,
        David


        From: Dav Glass <davglass@...>
        To: ydn-javascript@yahoogroups.com
        Sent: Fri, October 2, 2009 1:39:57 PM
        Subject: Re: [ydn-javascript] managing RTE toolbar

         

        Try the toolbarLoaded event:

        myEditor.on( 'toolbarLoaded' , setImageIcon) ;

        On Fri, 02 Oct 2009, David wrote:

        > Having a little problem. I want to limit the number of images to 1, in a text document. I've written a function ('setImageIcon( )') which looks for the presence of a '<img'. If it finds it, it trys to disable the 'insertimage' button.
        >
        > It works fine except when on loading the page. Here's what I've got on loading the window:
        >
        > var myEditor;
        >
        > function initForm(){
        > myEditor = new YAHOO.widget. Editor('story' ,{
        > width = 'auto',
        > height = '300px,
        > handleSubmit = true
        > });
        >
        > myEditor._defaultTo olbar.titlebar = false;
        > myEditor._defaultTo olbar.buttonType = 'advanced';
        >
        > myEditor.on( 'afterRender' , setImageIcon( ));
        > myEditor.render( );
        > }
        >
        > function setImageIcon( ){
        > ..code..
        > myEditor.toolbar. disableButton( 'insertimage' );
        > }
        >
        > The scripts fails on loading the page telling me that 'myEditor.toolbar is null or does not exist'. I've tried the most logical events to call setImageIcon( ) but have been unable to find one that does not generate this error.
        >
        > Am I going about this the wrong way or have I overlooked the logical event to make the function call..
        >
        > Thanks,
        > David
        >

        --
        Dav Glass
        davglass@gmail. com
        blog.davglass. com


        + Windows: n. - The most successful computer virus, ever. +
        + A computer without a Microsoft operating system is like a dog
        without bricks tied to its head +
        + A Microsoft Certified Systems Engineer is to computing what a
        McDonalds Certified Food Specialist is to fine cuisine +


      • Dav Glass
        It s actually working as expected, you also need to listen to the afterNodeChange event on the Editor since a NodeChange resets the buttons states. Dav ... --
        Message 3 of 4 , Oct 3, 2009
        • 0 Attachment
          It's actually working as expected, you also need to listen to the
          afterNodeChange event on the Editor since a NodeChange resets the
          buttons states.

          Dav

          On Fri, 02 Oct 2009, David Fealkoff wrote:

          > The error went away after I removed the parentheses following setImageIcon, however, it appears that I am still disabling the button too early.  I put an alert after myEditor.disableButton('insertimage') to make sure that the logic was working, which it was, and the alert popped up before the toolbar was fully rendered.  Subsequently when the toolbar rendered the 'insertimage' button was enabled.
          >
          > I retried the 'afterRender' event and it now gives me the same result as the 'toolbarLoaded' event, that is no error but the call to 'setImageIcon' happens before the toolbar is finally rendered.  Are there any later events that are accessible or ideas on other strategies?
          >
          > Thanks,
          > David
          >
          >
          >
          >
          > ________________________________
          > From: Dav Glass <davglass@...>
          > To: ydn-javascript@yahoogroups.com
          > Sent: Fri, October 2, 2009 1:39:57 PM
          > Subject: Re: [ydn-javascript] managing RTE toolbar
          >
          >  
          > Try the toolbarLoaded event:
          >
          > myEditor.on( 'toolbarLoaded' , setImageIcon) ;
          >
          > On Fri, 02 Oct 2009, David wrote:
          >
          > > Having a little problem. I want to limit the number of images to 1, in a text document. I've written a function ('setImageIcon( )') which looks for the presence of a '<img'. If it finds it, it trys to disable the 'insertimage' button.
          > >
          > > It works fine except when on loading the page. Here's what I've got on loading the window:
          > >
          > > var myEditor;
          > >
          > > function initForm(){
          > > myEditor = new YAHOO.widget. Editor('story' ,{
          > > width = 'auto',
          > > height = '300px,
          > > handleSubmit = true
          > > });
          > >
          > > myEditor._defaultTo olbar.titlebar = false;
          > > myEditor._defaultTo olbar.buttonType = 'advanced';
          > >
          > > myEditor.on( 'afterRender' , setImageIcon( ));
          > > myEditor.render( );
          > > }
          > >
          > > function setImageIcon( ){
          > > ..code..
          > > myEditor.toolbar. disableButton( 'insertimage' );
          > > }
          > >
          > > The scripts fails on loading the page telling me that 'myEditor.toolbar is null or does not exist'. I've tried the most logical events to call setImageIcon( ) but have been unable to find one that does not generate this error.
          > >
          > > Am I going about this the wrong way or have I overlooked the logical event to make the function call.
          > >
          > > Thanks,
          > > David
          > >
          >
          > --
          > Dav Glass
          > davglass@gmail. com
          > blog.davglass. com
          >
          >
          > + Windows: n. - The most successful computer virus, ever. +
          > + A computer without a Microsoft operating system is like a dog
          > without bricks tied to its head +
          > + A Microsoft Certified Systems Engineer is to computing what a
          > McDonalds Certified Food Specialist is to fine cuisine +
          >
          >
          >
          >
          >
          >

          --
          Dav Glass
          davglass@...
          blog.davglass.com


          + Windows: n. - The most successful computer virus, ever. +
          + A computer without a Microsoft operating system is like a dog
          without bricks tied to its head +
          + A Microsoft Certified Systems Engineer is to computing what a
          McDonalds Certified Food Specialist is to fine cuisine +
        Your message has been successfully submitted and would be delivered to recipients shortly.