PDA

View Full Version : problem in Mozilla



_eldar_
25 Oct 2006, 5:16 AM
Hello!
I'm trying to make loadable grid like in the sample "A Grid Component for Yahoo! UI - Part 2"
in IE everything works fine, but in Mozilla Firefox (v 1.5.0.7) page makes full refresh when I load new datas from other xml. What to do?

I use yui_0.11.4 & yui-ext.32.3.1

html file:


<html>
<head>
<title> New Document </title>
<meta name="Generator" content="EditPlus">
<meta name="Author" content="">
<meta name="Keywords" content="">
<meta name="Description" content="">
<script type="text/javascript" src="/js/yahoo/build/yahoo/yahoo-min.js"></script>
<script type="text/javascript" src="/js/yahoo/build/animation/animation-min.js"></script>
<script type="text/javascript" src="/js/yahoo/build/connection/connection-min.js"></script>
<script type="text/javascript" src="/js/yahoo/build/dom/dom-min.js"></script>
<script type="text/javascript" src="/js/yahoo/build/dragdrop/dragdrop-min.js"></script>
<script type="text/javascript" src="/js/yahoo/build/event/event-min.js"></script>
<script type="text/javascript" src="/js/yahoo/build/slider/slider-min.js"></script>

<script type="text/javascript" src="/js/yahoo.ext/yui-ext.js"></script>
<link rel="stylesheet" type="text/css" href="/js/yahoo.ext/resources/css/grid.css"/>


</head>

<body>
<div id="grid-example" style="width:534px;height:250px;overflow:hidden;position:relative;"></div>
<form name="example-form">
<input type="text" id="author_" value="Sidney Sheldon" size="24" >
<input type="submit" value="load new data"><span id="load-ind" class="loading-indicator" style="visibility:hidden;">Loading...</span>
</form>
<script type="text/javascript" src="grid-example-xml.js"></script>
</body>
</html>


grid-example-xml.js:


var XmlExample = {
init : function(){
var schema = {
tagName: 'Item',
id: 'ASIN',
fields: ['Author', 'Title', 'Manufacturer', 'ProductGroup']
};
this.dataModel = new YAHOO.ext.grid.XMLDataModel(schema);
this.dataModel.onLoad.subscribe(this.onLoad.createDelegate(this));

// example of custom renderer function, this hideous code was grabbed off the web
function money(mnt) {
mnt -= 0;
mnt = (Math.round(mnt*100))/100;
mnt = (mnt == Math.floor(mnt)) ? mnt + '.00' : ( (mnt*10 == Math.floor(mnt*10)) ? mnt + '0' : mnt);
return "$" + mnt;
}

// the DefaultColumnModel expects this blob to define columns. It can be extended to provide
// custom or reusable ColumnModels
var myColumns = [
{header: "Author", width: 120, sortable: true},
{header: "Title", width: 200, sortable: true},
{header: "Manufacturer", width: 120, sortable: true},
{header: "Product Group", width: 100, sortable: true}
];
var colModel = new YAHOO.ext.grid.DefaultColumnModel(myColumns);

// create the Grid
this.grid = new YAHOO.ext.grid.Grid('grid-example', this.dataModel, colModel);
this.grid.render();
this.dataModel.load('sheldon1.xml?111');
},

onLoad : function(){
this.grid.getSelectionModel().selectFirstRow();
},

search : function(e){
e.stopEvent();
var author = getEl('author_').dom.value;
if(!author){
alert("Author can't be blank, nice try buddy!");
return;
}
getEl('load-ind').show();
// params can be url encoded string or an object
var params = {'author': author};
// use callback to clear loading indicator
// this.dataModel.load('sheldon.xml?222', params, this.clearIndicator);
this.dataModel.load('sheldon.xml?222',null,this.clearIndicator);
},

clearIndicator : function(file){
getEl('load-ind').hide();
}
}
YAHOO.util.Event.on(window, 'load', XmlExample.init, XmlExample, true);

YAHOO.util.Event.onAvailable('example-form', function(){
getEl('example-form').mon('submit', XmlExample.search,
XmlExample, true);
});

jack.slocum
25 Oct 2006, 7:26 AM
Try adding the id "example-form" to the form element. Maybe firefox can't find it thru DOM by the name.

_eldar_
25 Oct 2006, 7:46 AM
Try adding the id "example-form" to the form element. Maybe firefox can't find it thru DOM by the name.

that works! thanks a lot!