0

Namespaces

Hi All

Hope you can help. I'm a C# coder and have just been getting into JavaScript and YUI, but I have been struggling with namespaces... I tried to do the following

.js file

CODEBOX
var mmu = {};

mmu.reading_list = function (oConfig) {

this.count_to_buy = oConfig.count_to_buy;


this.init = function () {
//do stuff
}
}



.php file

CODEBOX
		$script = "
<script type='text/javascript'>
var list_count = {
count_to_buy : " . $this->to_buy_count . ",
};
var newReadingList = new mmu.reading_list(list_count);
newReadingList.init();
</script>";



I tried a few variants of the above but couldn't get it to work, it just tells me that newReadingList is null. Once I remove the namespace it works fine.

Thanks in advance smile.gif

Alex

by
0 Replies

Recent Posts

in General Discussion at YDN