[Dojo-interest] dojox/app: How to push/pop a view programmatically?

Ramil Rakhmetov ramil_rakhmetov at peopleware.be
Mon Jan 27 03:01:01 EST 2014


hi KevG, i think that  your binding in "3" and "4" are wrong voor "this".

try:

*var self = this;*
 var importMenuItem = registry.byId("importMenuItem");
var searchMenuItem = registry.byId("searchMenuItem");


importMenuItem.on("click",lang.hitch(this.showSearch*.bind(self)*));

searchMenuItem.on("click",lang.hitch(this.showImport*.bind(self)*));





On Fri, Jan 24, 2014 at 3:00 PM, Ed Chatelain <elchatelain at gmail.com> wrote:

>    Well that seems odd, have you stopped in the debugger to verify that
> var importMenuItem = registry.byId("importMenuItem");
> is returning the menuItem widget?
> If so I would try to add a console.log into the function, to see if that
> is getting called, like this.
>
> importMenuItem.on("click",lang.hitch(this,function(e){
>                         console.log("inside importMenuItem onclick");
>                         this.showSearch(e);}));
> console.log("2");
>
>
>
> On Thu, Jan 23, 2014 at 4:57 PM, KevG <Kev.Graham at libertymutual.com>wrote:
>
>> Thanks for the quick responses.
>> I'm using dojo 1.9.2
>> With the code below clicking the buttons works and clicking the menuitems
>> does not. The buttons and the menuitems call the same functions. In both
>> cases we get to this line in on.js
>>
>> return target.dispatchEvent(nativeEvent) && nativeEvent;
>>
>> For the buttons, I then get into the hitch code (when I step in with the
>> debugger) but for the menuitems, I do not seem to get into the hitch code.
>>
>> main.html snippet
>>
>>         <button id="button1" data-dojo-type="dijit/form/Button"
>> type="button">Search</button>
>>         <button id="button2" data-dojo-type="dijit/form/Button"
>> type="button">Import</button>
>>
>>         <div id="operation" data-dojo-type="dijit/form/ComboButton">
>>                 Action&nbsp;
>>                 <div id="operationMenu" data-dojo-type="dijit/Menu">
>>                         <div id="searchMenuItem"
>> data-dojo-type="dijit/MenuItem">
>>                                 Search&nbsp;&nbsp;
>>                         </div>
>>                         <div id="importMenuItem"
>> data-dojo-type="dijit/MenuItem">
>>                                 Import&nbsp;&nbsp;
>>                         </div>
>>                 </div>
>>         </div>
>>
>>         <div id="contentDiv" dojoType="dijit/layout/ContentPane"></div>
>> main.js
>>
>> define(["dojo/dom", "dojo/dom-style", "dojo/_base/connect", "dojo/on",
>> "dijit", "dijit/registry", "dojo/_base/lang",
>>         "dijit/form/Button","dijit/form/ComboButton", "dijit/Menu",
>> "dijit/MenuItem","dijit/layout/ContentPane"],
>> function(dom, domStyle, connect, on, dijit, registry, lang,
>>                 Button, ComboButton, Menu, MenuItem, ContentPane) {
>>
>>         return {
>>                 init: function()
>>                 {
>>                         console.log("init");
>>
>>                         var button1 = registry.byId("button1");
>>
>> button1.on("click",lang.hitch(this,function(e){this.showSearch(e);}));
>>                         var button2 = registry.byId("button2");
>>
>> button2.on("click",lang.hitch(this,function(e){this.showImport(e);}));
>>                         console.log("1");
>>                         var importMenuItem =
>> registry.byId("importMenuItem");
>>
>>
>> importMenuItem.on("click",lang.hitch(this,function(e){this.showSearch(e);}));
>>                         console.log("2");
>>                         var searchMenuItem =
>> registry.byId("searchMenuItem");
>>
>>
>> searchMenuItem.on("click",lang.hitch(this,function(e){this.showImport(e);}));
>>                         console.log("3");
>>                 },
>>                 showSearch: function(/*Event*/ e)
>>                 {
>>                         console.log("showSearch " + e.target);
>>                         var transOpts = {
>>                                 title : "searchview",
>>                                 target : "searchview"
>>                         };
>>                         this.app.transitionToView(e.target,transOpts,e);
>>                         console.log("showSearch end");
>>                 },
>>                 showImport: function(/*Event*/ e)
>>                 {
>>                         console.log("showImport " + e.target);
>>                         var transOpts = {
>>                                 title : "importview",
>>                                 target : "importview"
>>                         };
>>                         this.app.transitionToView(e.target,transOpts);
>>                         console.log("showImport end");
>>                 }
>>
>>         };
>>
>> });
>>
>> config.json snippet
>>
>> "views": {
>>                 "topview": {
>>                         "controller" : "appBase/controllers/main.js",
>>                         "template": "appBase/views/main.html"
>>                 },
>>                 "searchview": {
>>                         "controller" : "appBase/controllers/search.js",
>>                         "constraint": "contentDiv",
>>                         "template": "appBase/views/search.html"
>>                 },
>>                 "importview": {
>>                         "constraint": "contentDiv",
>>                         "template": "appBase/views/import.html"
>>                 },
>>                 "blankview": {
>>                         "constraint": "contentDiv",
>>                         "template": "appBase/views/blank.html"
>>                 }
>>         }
>>
>>
>>
>>
>>
>> --
>> View this message in context:
>> http://dojo-toolkit.33424.n3.nabble.com/dojox-app-How-to-push-pop-a-view-programmatically-tp3995185p4000824.html
>> Sent from the Dojo Toolkit mailing list archive at Nabble.com.
>> ________________________________________________________
>> Dojo Toolkit: http://dojotoolkit.org/
>> Tutorials: http://dojotoolkit.org/documentation/
>> Reference Guide: http://dojotoolkit.org/reference-guide
>> API Documentation: http://dojotoolkit.org/api
>>
>> Dojo-interest at mail.dojotoolkit.org
>> To unsubscribe, visit:
>> http://mail.dojotoolkit.org/mailman/listinfo/dojo-interest
>>
>
>
> ________________________________________________________
> Dojo Toolkit: http://dojotoolkit.org/
> Tutorials: http://dojotoolkit.org/documentation/
> Reference Guide: http://dojotoolkit.org/reference-guide
> API Documentation: http://dojotoolkit.org/api
>
> Dojo-interest at mail.dojotoolkit.org
> To unsubscribe, visit:
> http://mail.dojotoolkit.org/mailman/listinfo/dojo-interest
>
>


-- 
Met vriendelijke groeten,

Ramil Rakhmetov


*PEOPLEWARE*
Duwijckstraat 17
2500 Lier - Belgium
+32 3 448.33.38
Facebook<http://www.facebook.com/pages/Peopleware/115011795207742>
Twitter <http://twitter.com/#!/PeopleWareBE>
www.peopleware.be
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.dojotoolkit.org/pipermail/dojo-interest/attachments/20140127/5d87fc09/attachment.htm 


More information about the Dojo-interest mailing list