PDA

View Full Version : insertAdjacentHTML error



dflkid
23 Oct 2006, 5:22 PM
I'm trying to set up a page using your remote dataset with the datagrid example, but I keep getting a javascript error stating "InsertAdjacentHTML is null or not an object". I'm using your latest release and including the following:

build/yahoo/yahoo.js
build/dom/dom.js
build/event/event.js
build/dragdrop/dragdrop.js
build/animation/animation.js
build/connection/connection.js
build/container/container.js
yui-ext.32/yui-ext.js

Any thoughts?

genius551v
23 Oct 2006, 5:47 PM
seria necesario ver mas codigo para poder decirte algo hacerca de lo que te falta, a mi primera impresion te faltaria your-editor-gird.js que es el que construye la grilla a partirde un div en la pag html, pero como te digo seria necesario ver el resto del codigo o si es posible postear un ejemplo.

Por el momento puedo referenciar un ejemplo que construi con ExampleEditor.js de jack.

http://www.cadenatextilconfeccion.com/botech/examples_jack/grid_editor.htm

...a consideracion del respetable jack...

jack.slocum
23 Oct 2006, 6:59 PM
Like he said, can you post some code or better yet put up a page? It's impossible to just guess.

dflkid
24 Oct 2006, 6:52 AM
Here's what I'm running. It's an example I found in the forums. Unfortunately I can't post to a public location.


<DOCTYPE>

<html>
<head>
<title>Untitled</title>

<link>

<script></script>
<script></script>
<script></script>
<script></script>
<script></script>
<script></script>
<script></script>
<script></script>



<script>
var urlColList = [
{header: "Feeds", width: 180, sortable: true},
{header:"Link", width: 20, sortable: false} // this would be hidden
];
var urlCM = new YAHOO.ext.grid.DefaultColumnModel(urlColList);

var urlSchema = {
tagName: 'site',
id: 'use-index',
fields: ['feed','link']
};
urlDM = new YAHOO.ext.grid.XMLDataModel(urlSchema);
urlDM.setDefaultSort(urlCM, 1, 'ASC');

urlSM = new YAHOO.ext.grid.SingleSelectionModel();
urlSM.onRowSelect.subscribe(this.loadFeedUrl, this, true);
urlGrid = new YAHOO.ext.grid.Grid('feed-list', this.urlDM, urlCM, this.urlSM);
urlGrid.render();

urlDM.load('test.xml');

</script>


</head>

<body>

<div></div>


</body>
</html>

The div contains: id="feed-list" class=ygrid-mso style="width:630px;height:250px;overflow:hidden;position:relative;"

jack.slocum
24 Oct 2006, 10:07 AM
You are loading and creating the grid inline (before the DOM exists). You will need to attach to onDocumentReady (preferred) or window 'load' to create the grid after the document and your grid's container element exist.

All of the examples do this so it shouldn't be too hard to figure out. Let me know if you need any help.

Jack

dflkid
24 Oct 2006, 3:48 PM
That was it, and it was so easy. I couldn't find the onDocumentReady in the docs, so I used the window load event. :? Thanks for the help and keep up the amazing work. My updated code is below...


var DataGrid = {
init : function(){

var urlColList = [
{header: "Feeds", width: 180, sortable: true},
{header:"Link", width: 20, sortable: false} // this would be hidden
];
var urlCM = new YAHOO.ext.grid.DefaultColumnModel(urlColList);

var urlSchema = {
tagName: 'site',
id: 'use-index',
fields: ['feed','link']
};
urlDM = new YAHOO.ext.grid.XMLDataModel(urlSchema);
urlDM.setDefaultSort(urlCM, 1, 'ASC');

urlSM = new YAHOO.ext.grid.SingleSelectionModel();
urlGrid = new YAHOO.ext.grid.Grid('feed-list', urlDM, urlCM);
urlGrid.render();

urlDM.load('test.xml');
}
}
YAHOO.util.Event.on(window, 'load', DataGrid.init, DataGrid, true);

jack.slocum
24 Oct 2006, 5:40 PM
It appears JSDoc didn't pick up onDocumentReady. I hate JSDoc!

Here's the docs and sig:



/**
* Fires when the document is ready (before onload and before images are loaded)
* @param {Function} fn The method the event invokes
* @param {Object} scope An arbitrary object that will be
* passed as a parameter to the handler
* @param {boolean} override If true, the obj passed in becomes
* the execution scope of the listener
*/
this.onDocumentReady = function(fn, scope, override){...}


Here's the edit:


// YAHOO.util.Event.on(window, 'load', DataGrid.init, DataGrid, true);
YAHOO.ext.EventManager.onDocumentReady(DataGrid.init, DataGrid, true);


It fires when the dom is ready and doesn't wait for images and resources so it is better for initialization code.