?
Solved

Build element dynamically

Posted on 2014-03-10
2
Medium Priority
?
241 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 58

Accepted Solution

by:
Gary earned 2000 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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Introduction Knockoutjs (Knockout) is a JavaScript framework (Model View ViewModel or MVVM framework).   The main ideology behind Knockout is to control from JavaScript how a page looks whilst creating an engaging user experience in the least …
Introduction JSON is an acronym for JavaScript Object Notation.  It is a text-string data transport mechanism, capable of representing simple or complex data structures in a consistent and easy-to-read manner.  Similar in concept to XML, but more e…
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…
Suggested Courses
Course of the Month10 days, 23 hours left to enroll

770 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