I have 6 different datatables. I created one massive YUI dialogbox. I need to have different views depending on which datatable is being accessed.

I cant seem to be able to call the function?

do I need more arguments to point to the 'datatable' first and then to point to 'Dialog'?

this is the function

var onDialog = function(oArgs){
	 	var elAnchor = oArgs.target;
                var record = this.getRecord(elAnchor);
             	var column = this.getColumn(elAnchor);
			 	var table=document.getElementById("editDialog");
			 	var thead = table.getElementsByTagName("THEAD")[0];
				var tbody = table.getElementsByTagName("TBODY")[0];
				var displayStyle;
			
				for (var r = 0; r < tbody.rows.length; r++) {
	
					
					if ('firsttable') {
						//editDialog.setHeader(label = "Edit BU:");
						if (tbody.rows[r].id == "editfirstTableRow") {
						
							displayStyle = '';
						}else {
							displayStyle = 'none';
						}
						tbody.rows[r].style.display = displayStyle;
						
						document.getElementById("editfirstinput").value = record.getData('name');
						
						}
					 
					else if('secondtable') {
						//	editDialog.setHeader(label = "Edit Header 2:");
							if (tbody.rows[r].id == "editsecondTableRow") {
							
								displayStyle = '';
							}else {
								displayStyle = 'none';
							}
							tbody.rows[r].style.display = displayStyle;
								document.getElementById("editsecondinput").value = record.getData('name');
						
						}

				 }
				  editdialog.render();
				 
				 editdialog.show();
					 
			}
			
		}


this is where/how the function is being called
anotherTable is an instance of datatable 'firsttable'

anotherTable.dt.subscribe('linkClickEvent', function(oArgs){
          var elAnchor = oArgs.target;
          var record = this.getRecord(elAnchor);
          var column = this.getColumn(elAnchor);
          if (column.key == 'action') {
		  	 if (elAnchor.hash.substr(1) == 'edit') {
[B]			 	anotherTable.dt.subscribe('linkClickEvent', onDialog);[/B]
[U]

[B]another2Table is an instance of datatable 'secondtable'[/B][/U]
 another2Table.dt.subscribe('linkClickEvent', function(oArgs){
          var elAnchor = oArgs.target;
          var record = this.getRecord(elAnchor);
          var column = this.getColumn(elAnchor);
          if (column.key == 'action') {
		  	 if (elAnchor.hash.substr(1) == 'edit') {
[B]			 	another2Table.dt.subscribe('linkClickEvent', onDialog);[/B]
			  
			 }
Member Avatar for tawes01

All I'm seeing here is that in the definition of the function, you assign it one parameter (the variable in quotes). when you call it, you don't have that variable, or even parentheses. For example,

var add=function(x,y) {return (x+y)};
var a=add(1,2);
var b=add();
var c=add;

variable a would call the function, and return 3.
variable b would create an error.
variable c (which is what you have) will do nothing. Not even an error.
If you don't want to pass anything, then use null, void, false, 0, or "", depending on the type of variable being passed.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.