Opening Cerabox on the fly and adding content to it..

88 views
Skip to first unread message

Andree Christaldi

unread,
Feb 26, 2013, 7:35:19 PM2/26/13
to cer...@googlegroups.com
Hi Cerabox,

Firstly, thanks for making such a great product.. good examples, documentation..etc, very much appreciated.

I am trying to create a CeraBox on the fly, and add some content - looking at this support forum, I could only find one example of creating a box on the fly but setting the internal content just doesn't seem to work.

My code:

var el = new Element('a',{'href':'#test'}).cerabox({displayTitle: false});
CeraBoxWindow.setContent('hello world');
el.fireEvent('click');
CeraBoxWindow.setContent('hello world');

.. I tried setting the 'setContent' before and after the window opened .. just because I've tried everything and nothing seems to work. 

Ideally I'd expect some kind of functionality like:

var box = new CeraBox( null, {} );
box.setContent('hello world');
box.openWindow(); 

^ .. ? 

Any help, most appreciated.

Andree

Cera media

unread,
Feb 27, 2013, 6:06:58 AM2/27/13
to cer...@googlegroups.com
Hi Andree,

Opening a CeraBox on the fly is a bit of a pain, it relies on the anchor element and its href attribute. Anyway your method should work, did you try passing an element instead of plain text?

CeraBoxWindow.setContent(new Element('p',{'text':'Test'}));

I think in your case the best thing to use is the variable method (example 9). To make your script work it should be something like this:

window.ceraboxContent = "Hello World";
// Or var ceraboxContent = "Hello World"; in the global scope

var el = new Element('a',{'href':'#$ceraboxContent'}).cerabox({displayTitle: false});
el.fireEvent('click');

I hope this helps!
Cheers

Op woensdag 27 februari 2013 01:35:19 UTC+1 schreef Andree Christaldi het volgende:

Andree Christaldi

unread,
Feb 27, 2013, 6:21:41 AM2/27/13
to cer...@googlegroups.com
Hi Cera Media,

Thanks very much for the prompt reply.

The example you provided about using the variable method (example 9) works as expected. . . but the other usage, still doesn't. 

I've included an example on js fiddle: http://jsfiddle.net/r8QjF/1/

I don't know if this is expected behaviour and I'm just doing something wrong ? 

--

Also, this needing the anchor element, is it not worth coding this out so that the Cerabox can be that bit more flexible ? 


Kind Regards & Thanks again for the help,
Andree
Reply all
Reply to author
Forward
0 new messages