Uploaded image for project: 'Alloy'
  1. Alloy
  2. ALOY-817

Wrong method used to add an event listener when using custom namespace in markup

    Details

      Description

      Problem description

      When adding an onClick event to a Map view (using the Android Map module), instead of using addEventListener, alloy is using on().

      Steps to reproduce

      1) Create a new Alloy app
      2) Use the following code in index.xml:

      <Alloy>
        <Window>
          <View id="map2" ns="Alloy.Globals.Map" onClick="report"/>
        </Window>
      </Alloy>
      

      Add a report function in index.js:

      function report(event) {
        alert('Hello');
      }
       
      $.index.open();
      

      Assign the value to Alloy.Globals.Map in alloy.js:

      Alloy.Globals.Map = Ti.Platform.osname === 'android' ? require('ti.map') : Ti.Map;
      

      Results

      When running the app, the result of the onClick is:

      .__views.map2 = Alloy.Globals.Map.createView({
          id: "map2",
          ns: "Alloy.Globals.Map"
      });
      $.__views.index.add($.__views.map2);
      report ? $.__views.map2.on("click", report) : __defers["$.__views.map2!click!report"] = true;
      

      Using the normal Ti.Map, the listener is added using addEventListener.

      workaround

      Don't specify the event listener in the markup, just do it in the controller

      $.map2.addEventListener('click', function(e) {});
      

        Attachments

          Activity

            People

            • Assignee:
              tlukasavage Tony Lukasavage
              Reporter:
              dcassenti Davide Cassenti
            • Watchers:
              3 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Backbone Issue Sync

                • Backbone Issue Sync is enabled for your project, but we do not have any synchronization info for this issue.

                  Git Integration