Solved

Build element dynamically

Posted on 2014-03-10
2
229 Views
Last Modified: 2014-03-10
I'm trying to build by own dialogue box (having lots of issues trying to customise the jQuery UI one to my requirements).  The idea is not to have any requiments on external CSS, HTML or Javascript, just call it and it will prepend to the page, and give me the ability to customise items such as border and size later.

I built it fine static proof of concept fine:-
http://jsfiddle.net/45kmB/

However when I tried to build it dynamically (so I can just call the function and everything is added to the document) it doesn't seem to work.
http://jsfiddle.net/tonelm2/J8WqS/1/

 I have minified my code only to display the overlay initially which I think is the issue:-
http://jsfiddle.net/tonelm2/as5xf/


When I look at the code after its been executed, all I get is:-

<div></div>

It doesnt seem to store any of the CSS values Ive been adding, which I belive should be added in:-
					$(testOverlay).css('display', 'inline')
						.css('height','1000px')
						.css('position', 'absolute')
						.css('width', '1000px') 
						.css('opacity', '0.40') 
						.css('filter', 'alpha(opacity=40)') 
						.css('background', '#000')
						.css('top', '0') 
						.css('left', '0')
						.css('cursor', 'wait');

Open in new window


However as far as Im aware I can chain the CSS statments like this.

Anyone have any idea what I'm doing wrong?
0
Comment
Question by:tonelm54
2 Comments
 
LVL 58

Accepted Solution

by:
Gary earned 500 total points
ID: 39918479
Fixed up your code and just made your dynamic elements into objects e.g.
   
    var $testOverlay = $('<div/>');


http://jsfiddle.net/GaryC123/J8WqS/4/
0
 
LVL 16

Expert Comment

by:SriVaddadi
ID: 39918492
You seem to comment the below lines in the fiddle

    //$(testDialogue).prepend(testDialogueClose);
    //$(testDialogue).prepend(testDialogueTitle);
    //$(testDialogue).prepend(testDialogueBody);
    //$("body").append(testDialogue);

Hope its not the same case with your original code
0

Featured Post

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

Introduction HyperText Transfer Protocol (http://www.ietf.org/rfc/rfc2616.txt) or "HTTP" is the underpinning of internet communication.  As a teacher of web development I have heard many questions, mostly from my younger students who have come to t…
What is a Lightbox? A Lightbox is the effect you see when you click, for example, an image and the screen fades out and up pops the same image but in its full size dimensions. There are lots of Lightbox effects for jQuery. Problem is they are a…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

707 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now