Uploaded image for project: 'Appcelerator Studio'
  1. Appcelerator Studio
  2. TISTUD-7066

Runtime error with Studio-generated function event handlers

    Details

    • Type: Bug
    • Status: Closed
    • Priority: High
    • Resolution: Fixed
    • Affects Version/s: Release 3.4.1
    • Fix Version/s: Release 4.1.0
    • Component/s: Editor
    • Labels:
      None
    • Story Points:
      3
    • Sprint:
      2014 Sprint 25 Studio

      Description

      Steps:

      1. Create a new Alloy project.
      2. Open views/index.xml and add a new Label element (e.g.) with an event hander that specifies a function that doesn't exist in the controller, e.g. <Label onClick="fooBar"></Label>.
      3. Press Cmd+1/Ctrl+1 to open the 'Create event listener in controller file' dialog and press Enter to create the new handler.
      4. Save all files and build for simulator/device.

      Results:
      Runtime error, "Can't find variable fooBar" (ios) or "fooBar is not defined" (Android).

      Expected: No runtime error with generated event handler.

      One fix is to add var before the function statement:

      // this
      var blah = function(e) {
      	
      };
      // instead of this
      blah = function(e) {
      	
      };
      

      Or, to be consistent with the default Alloy template's onClick handler:

      function fooBar(e) {
       
      }
      

        Attachments

          Activity

            People

            • Assignee:
              smishra Sujeet Mishra
              Reporter:
              tstatler Tim Statler
              Reviewer:
              Christopher Williams
            • Watchers:
              3 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: