0

Hi I had a trouble figuring out where select's id is registered at attempted once more. Possible causes:- 1) ParseOnload and Parser.parse() on the same page 2) Giving the same id to another new select 3) Registering the same select with new id

I could not figure what cause the select to registered twice.

...
...
<div id='main_bContainer' data-dojo-type='dijit/layout/BorderContainer' data-dojo-props='design:"sidebar"'>
        <div id='paneA' class='cP_Left' data-dojo-type='dijit/layout/ContentPane' data-dojo-props='region:"left"'>  
            <div id='surfaceElement1' style='border:1px solid #ccc; margin-bottom:5px; width:317px; height:55px;'><!--these dimensions here in this line override the dimensions as set by createSurface function-->
            <div id='node_meterSelect'></div>   
            </div>

            <div id='surfaceElement2' style='border:1px solid #ccc; width:317px; height:200px;'><!--these dimensions here in this line override the dimensions as set by createSurface function-->
            <div id='node_cardSelect'></div>    
            </div>
        </div>
        <div id='paneB' class='cP_Right' data-dojo-type='dijit/layout/ContentPane'data-dojo-props='region:"center"'>
            <!--<div id='surfaceElement3' style='border:1px solid #ccc;'> <!--width:520px; height:400px;'><!--it's the size-->

            <!--</div>-->
        </div>
    </div>
...
...
...
var meter_Select = new Select
            ({store:memoStore1,
              style:{width:'140px'},
            }, "node_meterSelect");
            meter_Select.startup();

            on(meter_Select, 'change', function(evt)
            {
                    console.debug('Selected Card = '+ meter_Select.value);
                    request.post('listofcards.php',{data:{cardX : meter_Select.value},
                    handleAs:"json"}).then(function(response)
...
...

The error is "

Error: Tried to register widget with id==node_meterSelect but that id is already registered" What could be the problem? please advise.. Thanks in advance.

4

2 回答 2

0

Here is a working jsfiddle based on your code:

http://jsfiddle.net/JxpRC/2/

Maybe you used the id somewhere else in your code ?

require(["dijit/form/Select",
  "dojo/data/ObjectStore",
  "dojo/store/Memory","dojo/domReady!"
], function(Select, ObjectStore, Memory){

     var store1 = new Memory({
    data: [
      { id: "foo", label: "Foo" },
      { id: "bar", label: "Bar" }
    ]
  });
    var os = new ObjectStore({ objectStore: store1 });

var meter_Select = new Select
            ({store:os,
              style:{width:'140px'},
            }, "node_meterSelect");
            meter_Select.startup();
})
于 2013-03-19T07:59:56.827 回答
0

i found your solution. You do not map all the require values to the right variables ! So registry and combobox are not mapped right ! you map "combobox" on "on".

Take a look at this jsfiddle:

http://jsfiddle.net/ejEGr/7/

Your function head with missing parameters:

function (parser, ready, dom, domConstruct, gfx, declare, 
_WidgetBase, Memory, Select, ObjectStore, request, on)

After correction:

function (parser, ready, dom, domConstruct, gfx, declare, 
_WidgetBase, Memory, Select, ObjectStore, request,box,registry, on)

So i had to add box & registry and now everything should work fine.

于 2013-03-20T07:25:12.573 回答