jQuery event handlers inside Floatbox

Page: 1

Author Post
Member
Registered: Jul 2014
Posts: 3
Is this possible? I have a page that I ajax another page into the Floatbox modal. The page that I ajax in, by itself, has no problem listening for events. As soon as it is in the Floatbox, nothing seems to work.

Example of the functions I have tried:

Using fb.addEvent
fb.addEvent('bossSubmitZipButton', 'click', function(e){
var passBossZipDisplay = $("#dvZipcode input[name='txtZipcode']").val();
alert(passBossZipDisplay);
});

Using straight jQuery
$('#bossSubmitZipButton').click(function(e){
e.preventDefault();
var passBossZipDisplay = $("#dvZipcode input[name='txtZipcode']").val();
alert(passBossZipDisplay);
});

Any help is greatly appreciated.

Jym
Administrator
Registered: Aug 2008
Posts: 3382
This is another one of those "I'd have to see it on a live page to determine what's going on" cases.

Some of the terminology you are using is raising suspicions. You say you ajax another page into the Floatbox. Does this mean you are setting type:ajax in its options? You also refer to that ajax content as a 'page' and say that it functions fine outside of the Floatbox. But type:ajax is just for bringing in HTML snippets that become part of the main page document. This is true for any AJAX content import, whether using Floatbox or not. It's not appropriate to bring in an entire page or document into another document using AJAX. Doing so will duplicate your scripts, give you duplicate html, head and body elements, and probably a bunch of other illegal headaches as well.

If you're bringing in a self-contained, stand-alone page, remove type:ajax from the options and let it load as an iframe. If you want to bring it in as type:ajax, just deliver the basic HTML snippet that you want to display. It will be part of the importing document so if you want to script against the new content, you would just use the script instances that are already present on the base page.
Member
Registered: Jul 2014
Posts: 3
You're exactly right. I shouldn't be using type:ajax. I will be bringing in a whole self contained, stand alone .jsp page. iframe is exactly how I should be doing this. Thanks so much for your speedy reply.

Jym

Page: 1