Hello !
I'm newbies in Dojo and i'm trying to replace Ajax InnerHtml by setHref or setContent ContentPane for get dojo widget functionality and javascript script in my div. My code is :
...
<script src="./yui/build/history/history.js"></script>
...
...
<div id="conteneur" dojoType="dijit.layout.ContentPane" parseOnLoad="true" style="background-color:green;">
<div id="loading"></div>
</div>
...
<script src="./yui/build/history/history.js"></script>
...
...
<div id="conteneur" dojoType="dijit.layout.ContentPane" parseOnLoad="true" style="background-color:green;">
<div id="loading"></div>
</div>
...
And i load and try to set response object by history.js script :
dojo.require("dijit.TitlePane");
dojo.require("dijit.form.Button");
dojo.require("dojo.parser");
dojo.require("dojo.back");
dojo.require("dijit.Dialog");
dojo.require("dijit.layout.ContentPane");
....
function successHandler(obj) {
YAHOO.example.container.wait.hide();
// Use the response...
//YAHOO.util.Dom.get("conteneur").innerHTML = obj.responseText;
//setInnerHTML(YAHOO.util.Dom.get("conteneur"), obj.responseText);
//YAHOO.util.Dom.setInnerHTML(obj.responseText);
//YAHOO.util.Dom.setInnerHTML(YAHOO.util.Dom.get("conteneur"), obj.responseText);
//dojo.byId('conteneur').innerHTML = obj.responseText;
//dojo.parser.parse(dojo.byId('conteneur'));
var Content = dojo.byId('conteneur');
Content.setHref(obj.responseText);
}
dojo.require("dijit.form.Button");
dojo.require("dojo.parser");
dojo.require("dojo.back");
dojo.require("dijit.Dialog");
dojo.require("dijit.layout.ContentPane");
....
function successHandler(obj) {
YAHOO.example.container.wait.hide();
// Use the response...
//YAHOO.util.Dom.get("conteneur").innerHTML = obj.responseText;
//setInnerHTML(YAHOO.util.Dom.get("conteneur"), obj.responseText);
//YAHOO.util.Dom.setInnerHTML(obj.responseText);
//YAHOO.util.Dom.setInnerHTML(YAHOO.util.Dom.get("conteneur"), obj.responseText);
//dojo.byId('conteneur').innerHTML = obj.responseText;
//dojo.parser.parse(dojo.byId('conteneur'));
var Content = dojo.byId('conteneur');
Content.setHref(obj.responseText);
}
And when i try to load my content to the content pane div i have error "Content.setHref" is not a function.
I have read another post and i have try Content.setContent= 'test'; or Content.setHref= 'test.php'; and my content in the div is not changed...
Have you any idea with my error in my code ?
Thanks for you're help.

I've made a FAQ entry on this,
as it gets asked quite frequently.
http://dojotoolkit.org/support/faq/how-do-i-execute-javascript-html-segm...
I've read you're entry
I 've read the faq entry. I always don't understand why i have error with setHref() or setContent() function.
I have test to put my dojo.require() and script in my index.php
dojo.require("dijit.TitlePane");
dojo.require("dijit.form.Button");
dojo.require("dojo.parser");
dojo.require("dojo.back");
dojo.require("dijit.Dialog");
dojo.require("dijit.layout.TabContainer");
dojo.require("dojox.layout.ContentPane");
dojo.require("dijit.layout.ContentPane");
...
<style type="text/css">
@import "./dojo/dijit/themes/tundra/tundra.css";
</style>
...
<div id="conteneur" dojoType="dijit.layout.TabContainer" style="height:400px">
<div dojoType="dojox.layout.ContentPane" href='test.php' executeScripts="true" parseOnLoad="true" style="background-color:green;">
<div id="loading"></div>
</div></div>
<script type="text/javascript">
var Content = dojo.byId('conteneur');
Content.setContent('test');
</script>
But i'm always error "Content.setContent('test');" is not a function
Thanks for you're reply
.setContent it a method of a
.setContent it a method of a dijit.layout.ContentPane. dojo.byId("conteneur") is a domNode reference. dijit.byId("conteneur") would be an object reference to your TabContainer. You need an object reference to the ContentPane, so give it an id, and then var content = dijit.byId("thatId").setContent('test');
Great !
Thanks You for your reply i have understand.
Thanks for your help.
what about functions?
I would like to encapsulate the logic for my menu controls in the content I am loading. For example my app menu is context sensitive, so when I fetch the HTML from the server I would like to bring in handler functions as well.
This works...
document.myHandler = function()
{
alert('clicked');
}
This does not...
function handler()
{
alert('never gonna happen');
}
This would be nice...
<div djoType="dijit.form.Button">
<script type="dojo/method" event="click">
alert('this would be good');
</script>
</div>
But this doesn't seem to work.
Obviously I can use the onClick attribute for something as simple as an alert but if the functions are more complex I would really like to separate them out.
Is something like this possible?