所以車削和圖像轉換成這樣試圖調用jQuery函數沒有事件
var imgCell = '<a href="javascript:storeInfo("text","text","ActiveProjects");"><img src="https://cubistmediagroup.sharepoint.com/sites/canvas/PublishingImages/details_open.png"></a>';
這將調用storeInfo功能,將採取「文本」,「文本」和「activeprojects,並將它們設置爲鏈接全局變量,這樣他們就可以被多個JavaScript函數中使用...
function storeInfo (filePath, webAddress, projectStatus){
theFilePath = filePath;
theWebAddress = webAddress;
controlButton(projectStatus);}
然後storeInfo功能我調用這個函數內...
function controlButton (projectStatus){
$('#'+projectStatus+' tbody td img').live('click', function() {
var theTable = ActiveProjectsTable;
var nTr = this.parentNode.parentNode.parentNode;
if (this.src.match('details_close'))
{
// This row is already open - close it
this.src = "https://cubistmediagroup.sharepoint.com/sites/canvas/PublishingImages/details_open.png";
theTable.fnClose(nTr);
}
else
{
// Open this row
this.src = "https://cubistmediagroup.sharepoint.com/sites/canvas/PublishingImages/details_close.png";
theTable.fnOpen(nTr, fnFormatDetails(theTable, nTr), 'details');
}
});
}
因此,第一次點擊IMG它調用存儲信息函數,該函數返回調用controlButton函數...然後在控制按鈕函數中有jquery代碼函數,需要再次點擊...我想知道是否有一種方法可以在沒有事件的情況下調用jquery函數,因此我不需要點擊兩次。
一旦controlButton被調用,我該如何調用jquery函數?
您的'live'在控件的內部'controlbutton'這隻會在您第一次點擊鏈接時安裝一個事件處理程序。然後它需要第二次點擊來執行安裝了'live'指令的'click'處理程序中的代碼 –