|
|
| Welcome to the Mac Forums forums. Please read the FAQ if you have questions. Register to participate. |
|
|||||||
| TouchArcade.com - iPhone Game Reviews and News |
![]() |
|
|
Thread Tools | Search this Thread |
|
|
#1 | ||
|
macrumors 6502a
Join Date: Dec 2005
Location: West Jordan, UT
|
AJAX expert needed.
Unfortunately I will not be able to provide links for this. I have a table that is displayed on the page. A user can press a button to added information to the database which in turn adds a new row to the table. I'm using AJAX to create the row without having to refresh. This works perfectly, finally.
Quote:
Here is the code that I use to create the row and the columns. Quote:
__________________
:Macbook Pro 2.8GHz, 4GB RAM, 512MB VRAM :20" Intel Dual Core 2.0GHz, 2GB RAM, 256MB VRAM :1.25GHz G4 Mac Mini w/ 1GB RAM :iPhone 3G Last edited by CANEHDN : Aug 7, 2008 at 07:24 PM. |
||
|
|
|
|
|
#2 | |
|
macrumors 68000
Join Date: Jul 2006
|
Quote:
Let me make sure I understand your problem first. Thickbox isnt working on the new rows that are generated using the javascript? The class attribute is used by thickbox to figure out which links thickbox gets applied to. Am I right? The problem could be a result of the code that thickbox uses to initialize itself when the page loads. This is the function that is being called I am talking about... Code:
//add thickbox to href & area elements that have a class of .thickbox
function tb_init(domChunk){
$(domChunk).click(function(){
var t = this.title || this.name || null;
var a = this.href || this.alt;
var g = this.rel || false;
tb_show(t,a,g);
this.blur();
return false;
});
}
This is the actual call of the function, along with other calls... Code:
$(document).ready(function(){
tb_init('a.thickbox, area.thickbox, input.thickbox');//pass where to apply thickbox
imgLoader = new Image();// preload image
imgLoader.src = tb_pathToImage;
});
I think that would probably fix it, assuming I understood your problem correctly.
__________________
TimeTable: The Freelancer's Tool |
|
|
|
|
|
|
#3 |
|
Thread Starter
macrumors 6502a
Join Date: Dec 2005
Location: West Jordan, UT
|
You understand it exactly. I will try to call that that function again once I close the popup, tomorrow. Hopefully it works. Thanks for the help.
__________________
:Macbook Pro 2.8GHz, 4GB RAM, 512MB VRAM :20" Intel Dual Core 2.0GHz, 2GB RAM, 256MB VRAM :1.25GHz G4 Mac Mini w/ 1GB RAM :iPhone 3G |
|
|
|
|
|
#4 |
|
macrumors 68000
Join Date: Jul 2006
|
Alright, then I would just copy this into your javascript, right after the new table row is created...
Code:
tb_init('a.thickbox, area.thickbox, input.thickbox');
__________________
TimeTable: The Freelancer's Tool |
|
|
|
|
|
#5 |
|
macrumors 65816
|
Erm...
Did you use setAttribute in this manner for your new row Code:
newrow.setAttribute('class', 'thickbox');
Code:
newrow.className = 'thickbox';
newrow.setAttribute('class', 'thickbox');
For adding events such as onclick, use attachEvent for IE and addEventListener for the rest
__________________
This is good, isn't it? |
|
|
|
|
|
#6 |
|
Thread Starter
macrumors 6502a
Join Date: Dec 2005
Location: West Jordan, UT
|
I've both suggestions and still have the same issue. I even tried calling the function on an onClick event in the image and link. Any more suggestions? I'm sure this can be done.
I'm such a dingle berry. You were right. I forgot to add parent. I hate working on problems and once you come close to getting it, you forget the basic stuff. Since I've added this, it works. Code:
parent.tb_init('a.thickbox, area.thickbox, input.thickbox');
__________________
:Macbook Pro 2.8GHz, 4GB RAM, 512MB VRAM :20" Intel Dual Core 2.0GHz, 2GB RAM, 256MB VRAM :1.25GHz G4 Mac Mini w/ 1GB RAM :iPhone 3G Last edited by CANEHDN : Aug 8, 2008 at 12:10 PM. |
|
|
|
![]() |
| Thread Tools | Search this Thread |
| Display Modes | |
|
|