Solved

Build element dynamically

Posted on 2014-03-10
2
234 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

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

I have answered several questions lately that were solved utilizing the power of jQuery's AJAX functions, so I thought I would write an article demonstrating the ease of use. Why should I use jQuery as opposed to regular JavaScript? Now I know…
Introduction A frequently asked question goes something like this:  "I am running a long process in the background and I want to alert my client when the process finishes.  How can I send a message to the browser?"  Unfortunately, the short answer …
The viewer will learn how to dynamically set the form action using jQuery.
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…

809 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