Titanium JIRA Archive
Appcelerator Community (AC)

[AC-2718] Alloy.createController is using wrong location, Alloy is defined after user controllers in generated code

GitHub Issuen/a
TypeBug
Priorityn/a
StatusClosed
ResolutionInvalid
Resolution Date2013-06-13T18:52:37.000+0000
Affected Version/sn/a
Fix Version/sn/a
ComponentsAlloy
LabelsAlloy
ReporterBraco
AssigneeDaniel Sefton
Created2013-04-28T00:39:55.000+0000
Updated2016-03-08T07:41:50.000+0000

Description

We have a widget that calls Alloy.createController. For some reason it's loading controllers form the main app's controller directory: (...)/Our.app/alloy/controllers/foo.js rather than the expected location: (...)/Our.app/alloy/widgets/this-widget/... In looking at the generated code, it seems that Alloy is defined after the controller: function Controller() { ... } var Alloy = require("alloy"), Backbone = Alloy.Backbone, _ = Alloy._; which means, I'm assuming, that we're getting the global Alloy instance and not this specific widget. This platform is difficult to debug on, so let me know if there's more information I can provide.

Comments

  1. Shak Hossain 2013-06-13

    Hi Braco, Can you please post a reproducible test case? Regards,
  2. Tony Lukasavage 2013-06-13

    When creating controllers in a widget, use the Widget object that is present only in widgets instead of Alloy. Using your example above:
       var controller = Widget.createController('foo');
       
    FYI, this is probably a better case for a Q&A question in the future.

JSON Source