Uploaded image for project: 'Tapestry'
  1. Tapestry
  2. TAPESTRY-742

LinkSubmit renders overly verbose JavaScript

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 4.0
    • 4.0
    • Framework
    • None

    Description

      The LinkSubmit component currently renders a JavaScript function for every LinkSubmit on the page. This is problematic for me because I have a page which could have over 100 LinkSubmits on it (3 LinkSubmits per item with up to 50 items per page). The current JavaScript function which is rendered looks like:

      function onclick_LinkSubmit_0()
      {
      var form = Tapestry.find('Form');

      if (form.events.onsubmit_handler())

      { Tapestry.find('LinkSubmit_0').value = "T"; form.onsubmit = null; form.submit(); }

      }

      The LinkSubmit component could, however, add a static JavaScript file which contains a single function which looks like:

      function onclick_LinkSubmit(form, link)
      {
      var form = Tapestry.find(form);

      if (form.events.onsubmit_handler())

      { Tapestry.find(link).value = "T"; form.onsubmit = null; form.submit(); }

      }

      The values of 'form' and 'link' can be determined at script processing time and the function can be executed by creating a URL which look like:

      <a href="javascript:onclick_LinkSubmit('Form', 'LinkSubmit_0');">Do Something</a>

      This will substantially reduce the amount of JavaScript sent to the browser on a page which includes many LinkSubmits.

      Attachments

        Activity

          People

            hlship Howard Lewis Ship
            rhavyn Chris Conrad
            Votes:
            1 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: