You're doing some strange things. What I suppose is that you want a TextBox
inside a ContentPane
, if i'm not right, then forget the following answer.
There are several mistakes in this code:
While creating your appLayout
contentpane, you're providing the second argument (which you use to put "appLayout"
in. This argument is used to define the DOM node (or the ID of the DOM node) that should be used to place the contentpane at. You don't have a DOM node with an ID called appLayout
. For more information look at the API documention which says that the second parameter is the srcNodeRef
. The solution is to leave this parameter empty.
Then the second mistake is that you're placing the TextBox
inside the ContentPane
even before it was placed on the DOM itself and started up. So re-arranging your code so the ContentPane
is placed on the grid container first will work.
The complete code, with changes:
dojo.require('dojo.store.JsonRest');
dojo.require('dijit.layout.ContentPane');
dojo.require("dijit.form.Button");
dojo.require('dojox.grid.DataGrid');
dojo.require('dojo.data.ObjectStore');
dojo.require('dijit.form.TextBox');
dojo.require('dojox.data.AndOrReadStore');
dojo.require('dojo._base.xhr');
dojo.require('dojo.json')
dojo.require('dojo.domReady');
dojo.ready(function() {
var appLayout = new dijit.layout.ContentPane({
id: "appLayout"
});
appLayout.placeAt('gridContainer');
appLayout.startup();
var textBox = new dijit.form.TextBox({
name: "searchbox",
placeHolder: "Search ..."
});
textBox.placeAt('appLayout');
});
Or as a JSFiddle. The startup is probably not required to be able to place the TextBox, but now the code is grouped a bit better.
I would also like to suggest to update your code to use the asynchronous syntax (Dojo 1.7+) since the syntax you're using is deprecated since 1.7 and since you're using 1.9 I don't see any benefit from writing new code with the old syntax since it will not work in Dojo 2.0.