FCKeditor disabling toolbar items

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Sebarry
    New Member
    • Jul 2007
    • 69

    FCKeditor disabling toolbar items

    Hi,

    Probably not a great place for this post, but FCKeditor is very well used so hopefully someone can help.

    Basically I have a form with two buttons - an edit button that creates an FCKeditor instance and creates a dynamic save function and a save button that needs to do some Javascript stuff before submitting the form. The save stuff looks like this.


    Code:
    function doSave()
    {
          ....
          ....
          ....
          document.managePagesForm.submit();
    }
    
    function FCKeditor_OnComplete( editorInstance )
    {
       editorInstance.LinkedField.form.onsubmit = doSave;
    }
    Problem I have is that
    Code:
    document.managePagesForm.submit();
    doesn't do anything because of the save function, but if I make my save button of type submit instead of type button it won't do the Javascript stuff I need to do before submitting the form. Can I disable the save button or remove a FCKeditor instance dynamically after I have used it?

    Thanks,

    Sean
  • dmjpro
    Top Contributor
    • Jan 2007
    • 2476

    #2
    Have a try with this :-)

    [code=javascript]
    function doSave()
    {
    ....
    ....
    ....
    document.manage PagesForm.submi t();
    }

    function FCKeditor_OnCom plete( editorInstance, button_name )
    {
    editorInstance. LinkedField.for m["button_nam e"].onclick = doSave;
    }[/code]

    Here the button_name is ....
    [code=html]
    <input type = button value = "Save" name = "button_nam e">
    [/code]

    Good Luck.

    Kind regards,
    Dmjpro.

    Comment

    • Sebarry
      New Member
      • Jul 2007
      • 69

      #3
      Hi,

      Thanks for that. I've tried it but to no avail. Here's what I've tried.

      [code=html]
      <input type="button" value="Save Changes" id="button_name " name="button_na me" onclick="javasc ript:submitForm ()" />
      [/code]

      [/code]

      [code=javascript]
      function FCKeditor_OnCom plete( editorInstance )
      {
      editorInstance. LinkedField.for m["button_nam e"].onclick = doSave;
      }

      function doSave()
      {
      // Do stuff to getHtml from FCKeditor and update form
      }

      function submitForm()
      {
      // Write contents of DIVs to hidden input fields.
      document.form.s ubmit();
      }

      [/code]

      With the code you gave me how is "button_nam e" passed to
      Code:
      FCKeditor_OnComplete
      ? Should "button_nam e" be in quotes if it is passed as a parameter? What needs to happen is that the save button on the form (what I have called button_name) calls the submitForm function to submit the form and the save button in my FCKeditor instance calls the doSave function. Do you know where I can find the API documentation for FCKeditor? I would like to remove the instance once I'm finished with it. Do you know how to do that too?

      Sorry for the million and one questions.

      Thanks,

      Sean

      Originally posted by dmjpro
      Have a try with this :-)

      [code=javascript]
      function doSave()
      {
      ....
      ....
      ....
      document.manage PagesForm.submi t();
      }

      function FCKeditor_OnCom plete( editorInstance, button_name )
      {
      editorInstance. LinkedField.for m["button_nam e"].onclick = doSave;
      }[/code]

      Here the button_name is ....
      [code=html]
      <input type = button value = "Save" name = "button_nam e">
      [/code]

      Good Luck.

      Kind regards,
      Dmjpro.

      Comment

      • dmjpro
        Top Contributor
        • Jan 2007
        • 2476

        #4
        Originally posted by Sebarry
        Hi,

        Thanks for that. I've tried it but to no avail. Here's what I've tried.

        [code=html]
        <input type="button" value="Save Changes" id="button_name " name="button_na me" onclick="javasc ript:submitForm ()" />
        [/code]

        [/code]

        [code=javascript]
        function FCKeditor_OnCom plete( editorInstance )
        {
        editorInstance. LinkedField.for m["button_nam e"].onclick = doSave;
        }

        function doSave()
        {
        // Do stuff to getHtml from FCKeditor and update form
        }

        function submitForm()
        {
        // Write contents of DIVs to hidden input fields.
        document.form.s ubmit();
        }

        [/code]

        With the code you gave me how is "button_nam e" passed to
        Code:
        FCKeditor_OnComplete
        ? Should "button_nam e" be in quotes if it is passed as a parameter? What needs to happen is that the save button on the form (what I have called button_name) calls the submitForm function to submit the form and the save button in my FCKeditor instance calls the doSave function. Do you know where I can find the API documentation for FCKeditor? I would like to remove the instance once I'm finished with it. Do you know how to do that too?

        Sorry for the million and one questions.

        Thanks,

        Sean
        First tell me ....
        [code=javascript]
        editorInstance. LinkedField.... ..
        [/code]
        Is editorInstance. LinkedField a reference to a document?

        Kind regards,
        Dmjpro.

        Comment

        • Sebarry
          New Member
          • Jul 2007
          • 69

          #5
          editorInstance is a parameter passed to the On_Complete function. The rest I don't know, it's FCKeditor API syntax. I got the original code from http://wiki.fckeditor. net/Developer's_Gui de/Javascript_API scroll to the bottom of the page.

          Originally posted by dmjpro
          First tell me ....
          [code=javascript]
          editorInstance. LinkedField.... ..
          [/code]
          Is editorInstance. LinkedField a reference to a document?

          Kind regards,
          Dmjpro.

          Comment

          • dmjpro
            Top Contributor
            • Jan 2007
            • 2476

            #6
            Originally posted by Sebarry
            editorInstance is a parameter passed to the On_Complete function. The rest I don't know, it's FCKeditor API syntax. I got the original code from http://wiki.fckeditor. net/Developer's_Gui de/Javascript_API scroll to the bottom of the page.
            Have a try this!

            [code=html]
            <form name="form_name ">
            <input type = button name="button_na me" onclick = "JavaScript:sub mit()">
            </form>
            [/code]

            [code=javascript]
            function FCKeditor_OnCom plete( editorInstance )
            {
            editorInstance. LinkedField.for ms["form_name"].elements["button_nam e"].onclick = doSave;
            }
            [/code]

            Kind regards,
            Dmjpro.

            Comment

            • Sebarry
              New Member
              • Jul 2007
              • 69

              #7
              I'm a bit confused here, because the syntax seems to suggest that it is trying to link the save button on the form to the doSave Javascript function. I want to link the save button on the FCKeditor to the doSave Javascript function. The save button on the HTML form should do the Javascript submit stuff.

              Originally posted by dmjpro
              Have a try this!

              [code=html]
              <form name="form_name ">
              <input type = button name="button_na me" onclick = "JavaScript:sub mit()">
              </form>
              [/code]

              [code=javascript]
              function FCKeditor_OnCom plete( editorInstance )
              {
              editorInstance. LinkedField.for ms["form_name"].elements["button_nam e"].onclick = doSave;
              }
              [/code]

              Kind regards,
              Dmjpro.

              Comment

              • dmjpro
                Top Contributor
                • Jan 2007
                • 2476

                #8
                Originally posted by Sebarry
                I'm a bit confused here, because the syntax seems to suggest that it is trying to link the save button on the form to the doSave Javascript function. I want to link the save button on the FCKeditor to the doSave Javascript function. The save button on the HTML form should do the Javascript submit stuff.
                Can you Post some code, from where I can figure out when FCKeditor_OnCom plete function is called and the line editorInstance. LinkedField.... .
                And tell me something what you need and what is happening.
                Ok!

                Kind regards,
                Dmjpro.

                Comment

                • Sebarry
                  New Member
                  • Jul 2007
                  • 69

                  #9
                  Okie Dokies. Here we go.

                  [code=javascript]
                  function editSection(div Id)
                  {
                  var fck = new FCKeditor( "myFCKedito r" );
                  fck.BasePath = '/iwo/FCKeditor/';
                  fck.Value = divContent.inne rHTML;
                  fck.ToolbarSet = 'Basic';
                  alert( "Creating FCK" );
                  divContent.inne rHTML = fck.CreateHtml( );
                  }

                  function doSave()
                  {
                  alert( "Saving" );
                  var editor = FCKeditorAPI.Ge tInstance( "myFCKedito r" );
                  contentDiv.inne rHTML = editor.GetHTML( );
                  }

                  function submitForm()
                  {
                  alert( "Submitting " );
                  // Processing code goes here.
                  document.manage PagesForm.submi t();
                  }

                  function FCKeditor_OnCom plete( editorInstance )
                  {
                  editorInstance. LinkedField.for ms["managePagesFor m"].elements["button_nam e"].onclick = doSave;
                  }
                  [/code]

                  [code=html]
                  ....
                  ....
                  <input type="button" value="Save Changes" id="button_name " name="button_na me" onclick="javasc ript:submitForm ()" />
                  ...
                  ....
                  [/code]

                  The javascript function
                  Code:
                  editSection
                  is called when an edit button is clicked. This creates a FCKeditor instance (FCKeditor.net) and on completion of the instance creation the
                  Code:
                  FCKeditor_OnComplete
                  function is called. In this function I need to associate the save button from FCKeditor, not on my HTML form, with the doSave function that I have written. In other words, the doSave function should be called when the save button in FCKeditor is clicked. The submitForm function should be called when the "Save Changes" button in the HTML form is clicked.

                  Hope that helps.

                  Sean

                  Comment

                  • dmjpro
                    Top Contributor
                    • Jan 2007
                    • 2476

                    #10
                    Originally posted by Sebarry
                    Okie Dokies. Here we go.

                    [code=javascript]
                    function editSection(div Id)
                    {
                    var fck = new FCKeditor( "myFCKedito r" );
                    fck.BasePath = '/iwo/FCKeditor/';
                    fck.Value = divContent.inne rHTML;
                    fck.ToolbarSet = 'Basic';
                    alert( "Creating FCK" );
                    divContent.inne rHTML = fck.CreateHtml( );
                    }

                    function doSave()
                    {
                    alert( "Saving" );
                    var editor = FCKeditorAPI.Ge tInstance( "myFCKedito r" );
                    contentDiv.inne rHTML = editor.GetHTML( );
                    }

                    function submitForm()
                    {
                    alert( "Submitting " );
                    // Processing code goes here.
                    document.manage PagesForm.submi t();
                    }

                    function FCKeditor_OnCom plete( editorInstance )
                    {
                    editorInstance. LinkedField.for ms["managePagesFor m"].elements["button_nam e"].onclick = doSave;
                    }
                    [/code]

                    [code=html]
                    ....
                    ....
                    <input type="button" value="Save Changes" id="button_name " name="button_na me" onclick="javasc ript:submitForm ()" />
                    ...
                    ....
                    [/code]

                    The javascript function
                    Code:
                    editSection
                    is called when an edit button is clicked. This creates a FCKeditor instance (FCKeditor.net) and on completion of the instance creation the
                    Code:
                    FCKeditor_OnComplete
                    function is called. In this function I need to associate the save button from FCKeditor, not on my HTML form, with the doSave function that I have written. In other words, the doSave function should be called when the save button in FCKeditor is clicked. The submitForm function should be called when the "Save Changes" button in the HTML form is clicked.

                    Hope that helps.

                    Sean
                    Ok!
                    Try this one ...
                    [code=javascript]
                    function FCKeditor_OnCom plete( editorInstance )
                    {
                    editorInstance. LinkedField.for ms["managePagesFor m"].elements["button_nam e"].setAttribute(" onclick",doSave );
                    }
                    [/code]
                    Good Luck :-)

                    Kind regards,
                    Dmjpro.

                    Comment

                    • Sebarry
                      New Member
                      • Jul 2007
                      • 69

                      #11
                      Nah that's still not going to work. The line
                      Code:
                      editorInstance.LinkedField.forms["managePagesForm"].elements["button_name"].setAttribute("onclick",doSave);
                      needs to be of FCKeditor syntax, not Javascript. It needs to link the save button in FCKeditor to the doSave function, not the save button on my HTML form.

                      Originally posted by dmjpro
                      Ok!
                      Try this one ...
                      [code=javascript]
                      function FCKeditor_OnCom plete( editorInstance )
                      {
                      editorInstance. LinkedField.for ms["managePagesFor m"].elements["button_nam e"].setAttribute(" onclick",doSave );
                      }
                      [/code]
                      Good Luck :-)

                      Kind regards,
                      Dmjpro.

                      Comment

                      Working...