0
我在面板對話框中有一個數據表。數據表顯示ok ...但是....沒有事件正在註冊,喜歡排序,行選擇等等。不是香腸。如果數據表不在面板內,那麼行選擇,排序等工作就會很好。YUI數據表在面板中沒有註冊事件
這是我的代碼。如果你能指引我朝着正確的方向,我將永遠感激不盡。
YAHOO.util.Event.addListener(window, "load", function(){
function processPostpone(e)
{
var dom = YAHOO.util.Dom;
if(dom.get("user_rejected").value==3)
{
window.alert(dom.get("user_rejected_impossible").value);
}
else
{
var elTarget = YAHOO.util.Event.getTarget(e);
var attendance_id = elTarget.id;
attendance_id = attendance_id.substring(7, 15);
var handleYes = function() {
// postpone session
var callback = {
success : function(o)
{
if(o.responseText=="true")
{
// succesfully postponed session
var callback2 =
{
success: function(o)
{
try
{
messages = YAHOO.lang.JSON.parse(o.responseText);
}
catch (x)
{
alert("JSON Parse failed!");
return;
}
if(messages.ResultSet.count > 0)
{
// there are some other available sessions
var columndefs = [
{key:"name", label: "Session", sortable:false, resizeable:false},
{key:"location", label: "Location", sortable:false, resizeable:false},
{key:"start_date", label: "Start Date", sortable:false, resizeable:false}
];
var datasource = new YAHOO.util.DataSource(messages);
datasource.responseType = YAHOO.util.DataSource.TYPE_JSON;
datasource.responseSchema = {
resultsList: "ResultSet.Result",
fields: ["name","location","start_date"]
};
var datatable = new YAHOO.widget.DataTable("possibleSessionsDataTable", columndefs, datasource, {rowSingleSelect:true, zindex:999});
datatable.subscribe("rowMouseoverEvent", datatable.onEventHighlightRow);
datatable.subscribe("rowMouseoutEvent", datatable.onEventUnhighlightRow);
datatable.subscribe("rowClickEvent", datatable.onEventSelectRow);
datatable.focus();
var handleSubmit = function() {
// test
alert('You clicked submit');
}
var panel = new YAHOO.widget.Panel("panel2", { width:"600px", visible:false, modal: false, fixedCenter: true, draggable:false, close:false });
panel.setHeader("Other Sessions You May Be Able To Attend");
panel.setBody(dom.get("other_possible_sessions").innerHTML);
panel.setFooter('<div id="panelFooter"></div>');
panel.showEvent.subscribe(function() {
var button1 = new YAHOO.widget.Button({
type: 'button',
label: 'Submit',
container: 'panelFooter'
});
button1.on("click", handleSubmit);
}, panel, true);
panel.render("container");
panel.show();
}
},
failure: function(o)
{
}
}
var conn = YAHOO.util.Connect.asyncRequest("POST", "/ajax/possiblesessions.json?id=" + attendance_id, callback2);
}
else
{
window.alert("Sorry, there was an error.");
}
},
failure : function(o)
{
window.alert("Sorry, there was an error.");
}
}
var conn = YAHOO.util.Connect.asyncRequest("POST", "/ajax/postponesession.json?id=" + attendance_id, callback);
var loading = new YAHOO.widget.Panel("wait",
{ width:"300px",
fixedcenter:true,
close:false,
draggable:true,
zindex:4,
modal:false,
visible:false
}
);
this.hide();
/*loading.setHeader("Rejecting session...");
loading.setBody('<img src="http://l.yimg.com/a/i/us/per/gr/gp/rel_interstitial_loading.gif" />');
loading.render(document.body);
loading.show();*/
};
var handleNo = function() {
this.hide();
};
var dialog = new YAHOO.widget.SimpleDialog("dialog",
{ width: "300px",
fixedcenter: true,
visible: false,
draggable: false,
close: true,
text: document.getElementById("reject_alert_text").innerHTML,
modal: false,
icon: YAHOO.widget.SimpleDialog.ICON_HELP,
constraintoviewport: true,
buttons: [ { text:"Yes", handler:handleYes, isDefault:true },
{ text:"No", handler:handleNo } ]
});
dialog.setHeader("Reject session?");
// Render the Dialog
dialog.render(document.body);
dialog.show();
}
}
// create postpone button
var elms = YAHOO.util.Dom.getElementsByClassName("reject");
// loop over all the elements and attach a click event
for(var i=0,j=elms.length;i<j;i++)
{
var el = document.getElementById(elms[i].id);
YAHOO.util.Event.addListener(el, "click", processPostpone);
}
var tabView = new YAHOO.widget.TabView('tabs');
});
我爲長碼片斷表示歉意。
預先感謝您。
非常好。我會放棄這一點。非常感謝你:-) – Flukey 2009-12-16 13:32:39
因此增加了一個範圍: \t \t \t \t \t \t \t \t datatable.subscribe( 「radioClickEvent」 功能(oArgs){ \t \t \t \t \t \t \t警報('你好單選按鈕點擊!'); \t \t \t \t \t \t \t},panel,true); 但是,唉,即使範圍是爲面板....它不喜歡它:-(我非常困惑和惱火。謝謝:-) – Flukey 2009-12-16 14:03:42
傑米,只是想知道如果你曾經解決過這個問題?我正在面對類似的問題,在一個yui3標籤視圖內的tableView中表現得有點奇怪。謝謝 - 巴特 – 2010-07-28 21:04:05