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

RTE and Connection Manager

Expand Messages
  • Brian
    Fellow YUIers ;-), I m using the YUI Connection Manager to do an AJAX post (YAHOO.util.Connect.asyncRequest...) on a form that has an RTE. The handleSubmit
    Message 1 of 4 , Sep 2, 2008
    • 0 Attachment
      Fellow YUIers ;-),
      I'm using the YUI Connection Manager to do an AJAX post
      (YAHOO.util.Connect.asyncRequest...) on a form that has an RTE. The
      handleSubmit does not seem to work with asyncRequest (it works if I
      just do a regular synch post). With the AJAX post the textarea does
      not get the HTML from the RTE.
      Is there an event that I can listen to (on the form) and then call
      saveHTML on the RTE before the submit (looks like I'm looking for a
      onBeforeSubmit event or something along those lines.

      Thanks,
      Brian
    • Brian
      ... By the way I did try... YAHOO.util.Event.on( my_form , submit , function(e) { YAHOO.util.Event.stopEvent(e); my_editor.saveHTML(); }); but I guess that s
      Message 2 of 4 , Sep 2, 2008
      • 0 Attachment
        --- In ydn-javascript@yahoogroups.com, "Brian" <bsbodden@...> wrote:
        >
        > Fellow YUIers ;-),
        > I'm using the YUI Connection Manager to do an AJAX post
        > (YAHOO.util.Connect.asyncRequest...) on a form that has an RTE. The
        > handleSubmit does not seem to work with asyncRequest (it works if I
        > just do a regular synch post). With the AJAX post the textarea does
        > not get the HTML from the RTE.
        > Is there an event that I can listen to (on the form) and then call
        > saveHTML on the RTE before the submit (looks like I'm looking for a
        > onBeforeSubmit event or something along those lines.
        >
        > Thanks,
        > Brian
        >

        By the way I did try...

        YAHOO.util.Event.on('my_form', 'submit', function(e) {
        YAHOO.util.Event.stopEvent(e);
        my_editor.saveHTML();
        });

        but I guess that's all bypassed by the AJAX post.
      • Dav Glass
        Brian -- Try this example: http://developer.yahoo.com/yui/examples/editor/post_editor.html Dav Dav Glass dav.glass@yahoo.com blog.davglass.com + Windows: n. -
        Message 3 of 4 , Sep 2, 2008
        • 0 Attachment
          Brian --

          Try this example:
          http://developer.yahoo.com/yui/examples/editor/post_editor.html

          Dav

          Dav Glass
          dav.glass@...
          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 +



          ----- Original Message ----
          > From: Brian <bsbodden@...>
          > To: ydn-javascript@yahoogroups.com
          > Sent: Tuesday, September 2, 2008 2:25:07 AM
          > Subject: [ydn-javascript] Re: RTE and Connection Manager
          >
          > --- In ydn-javascript@yahoogroups.com, "Brian" wrote:
          > >
          > > Fellow YUIers ;-),
          > > I'm using the YUI Connection Manager to do an AJAX post
          > > (YAHOO.util.Connect.asyncRequest...) on a form that has an RTE. The
          > > handleSubmit does not seem to work with asyncRequest (it works if I
          > > just do a regular synch post). With the AJAX post the textarea does
          > > not get the HTML from the RTE.
          > > Is there an event that I can listen to (on the form) and then call
          > > saveHTML on the RTE before the submit (looks like I'm looking for a
          > > onBeforeSubmit event or something along those lines.
          > >
          > > Thanks,
          > > Brian
          > >
          >
          > By the way I did try...
          >
          > YAHOO.util.Event.on('my_form', 'submit', function(e) {
          > YAHOO.util.Event.stopEvent(e);
          > my_editor.saveHTML();
          > });
          >
          > but I guess that's all bypassed by the AJAX post.
          >
          >
          >
          > ------------------------------------
          >
          > Yahoo! Groups Links
          >
          >
          >
        • Brian
          Dav, Thanks, you da man. I don t know how I missed that. It works fairly well now. But I ve added yet one more challenge to my YUI hurdles. - I have an
          Message 4 of 4 , Sep 5, 2008
          • 0 Attachment
            Dav,
            Thanks, you da man. I don't know how I missed that. It works fairly
            well now. But I've added yet one more challenge to my YUI hurdles.

            - I have an application where I have a tabview with two tabs
            - The content from the tabs is served by a ruby app
            - In one tab I have a "list" of entries
            - The second tab contains a form that creates "new" entries
            - The "new" tab uses connection manager to post the form
            - The result of the posting is the id of the new record
            - The callback from the ajax post is on the main page that contains
            the tabview
            - The callback is supposed to:
            - clear the form
            - switch to the "list" tab
            - refresh the content of the "list" tab
            - scroll to the newly added item and highlight it with some animation

            So far the page you helped me with works standalone. I suspect I have
            a Javascript namespacing issue that stems from my lack of
            understanding of how any <script/> tags from tabs are merged into the
            main page.
            I got everything working except for the call to editor.saveHTML(). I'm
            using firebug and I just don't see the editor object in the dom for
            some reason. Here's a snippet of what's in each page:

            This script is server generated and lives in the "new" tab:

            <script type="text/javascript">
            function create_and_configure_body_editor() {
            var Dom = YAHOO.util.Dom,
            Event = YAHOO.util.Event;

            var config = {
            height: '100px',
            width: '580px',
            dompath: false,
            animate: true,
            handleSubmit: false,
            focusAtStart: false
            };

            var editor = new YAHOO.widget.SimpleEditor('body', config);
            editor._defaultToolbar.titlebar = false;

            return editor;
            }

            var body_editor = create_and_configure_body_editor();
            body_editor.render();
            </script>

            If I load the new page by itself I do see the "body_editor" object.
            But I can't seem to find it when loaded into a tab. On that same "new"
            page there is a submit form script (also server generated):

            ...
            <script type="text/javascript">
            YAHOO.util.Event.onDOMReady(function () {
            var btn_save = new YAHOO.widget.Button({
            label:"Save Item",
            id:"save",
            container:"button_save",
            onclick:{
            fn: submit_item,
            obj: "",
            label: "Save Item "
            }
            });
            });
            </script>
            </form>
            <script type="text/javascript">
            submit_item = function() {
            // callback handler for article
            var item_callback = {
            customevents:{
            onSuccess:handleSuccess
            }
            };
            body_editor.saveHTML();

            // ajax enable form article
            var formObject = document.getElementById('item');
            YAHOO.util.Connect.setForm(formObject);
            var cObj = YAHOO.util.Connect.asyncRequest('post', '/item.submit',
            item_callback);
            }
            </script>

            Back on the main page I have the "handleSuccess" function:

            <script type="text/javascript">
            var handleSuccess = function(callbackObject) {
            // 1) clear the form fields in the new article form
            var form = document.getElementById('item');
            form.reset();
            // 2) refresh the contents of the article tab
            itemTab = tabView_yuitabs.getTab(0);
            itemTab.set('cacheData', false);
            // 3) switch to the items list tab
            tabView_yuitabs.set('activeIndex', 0);
            itemTab.set('cacheData', true);
            // 4) highlight the newly created item
            var attributes = {
            color: { to: '#06e' },
            backgroundColor: { to: '#e06' }
            };
            var anim = new YAHOO.util.ColorAnim('item_' +
            callbackObject.responseText, attributes);
            anim.animate();
            }
            </script>

            The post call returns the id of the new item created which are placed
            in divs with the id item_##id##.

            Everything works if I comment the editor call and the other thing that
            I haven't been able to figure out (JS rookie) is how to scroll down to
            the div that I want to animate (so if it is out of view I don't see it)

            Thanks in advance.

            Brian



            --- In ydn-javascript@yahoogroups.com, Dav Glass <dav.glass@...> wrote:
            >
            > Brian --
            >
            > Try this example:
            > http://developer.yahoo.com/yui/examples/editor/post_editor.html
            >
            > Dav
            >
            > Dav Glass
            > dav.glass@...
            > 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 +
            >
            >
            >
            > ----- Original Message ----
            > > From: Brian <bsbodden@...>
            > > To: ydn-javascript@yahoogroups.com
            > > Sent: Tuesday, September 2, 2008 2:25:07 AM
            > > Subject: [ydn-javascript] Re: RTE and Connection Manager
            > >
            > > --- In ydn-javascript@yahoogroups.com, "Brian" wrote:
            > > >
            > > > Fellow YUIers ;-),
            > > > I'm using the YUI Connection Manager to do an AJAX post
            > > > (YAHOO.util.Connect.asyncRequest...) on a form that has an RTE. The
            > > > handleSubmit does not seem to work with asyncRequest (it works if I
            > > > just do a regular synch post). With the AJAX post the textarea does
            > > > not get the HTML from the RTE.
            > > > Is there an event that I can listen to (on the form) and then call
            > > > saveHTML on the RTE before the submit (looks like I'm looking for a
            > > > onBeforeSubmit event or something along those lines.
            > > >
            > > > Thanks,
            > > > Brian
            > > >
            > >
            > > By the way I did try...
            > >
            > > YAHOO.util.Event.on('my_form', 'submit', function(e) {
            > > YAHOO.util.Event.stopEvent(e);
            > > my_editor.saveHTML();
            > > });
            > >
            > > but I guess that's all bypassed by the AJAX post.
            > >
            > >
            > >
            > > ------------------------------------
            > >
            > > Yahoo! Groups Links
            > >
            > >
            > >
            >
          Your message has been successfully submitted and would be delivered to recipients shortly.