Jump to content

Update page dynamically ?

Recommended Posts

Hello & Thanks; 

I am making great progress on my project , thanks to you folks .

But I do still have a problem with  'createElement' and 'appendChild' . 

They work fine but when I try to Drag the 'newly created div' it doesn't drag .

If I saveAs the page and open the saved page , The created 'div' Drag works fine . 

So it seems that something is not getting updated dynamically .

Pls , why does this happen , and how to fix it ?

Run page here: http://vmars.us/ShowMe/changeImage-WIP-Try-Drag-Create.html






Share this post

Link to post
Share on other sites

First, instead of setAttribute("draggable"  ) you should set the draggable property of the element, as element.draggable = true.

Once the element has been created, you have to call the dragElement() function to add the event listeners to this element. Without the event listeners the element cannot be draggable.

Share this post

Link to post
Share on other sites

Thanks Ingolme


Works great .

I have another problem , same program: 

in here:

var copyFromVar = "one"; 
function saveItAll() {
alert("Hello  from  function saveItAll()");
console.log("Hello  from  function saveItAll()");
var blankVar = "";
var  fromList   = document.getElementsByClassName("copyFrom");
var  intoList    = document.getElementsByClassName("pasteInto");
alert("fromList.length = " + fromList.length);

  for (var i = 0; i < fromList.length; i++) {
alert("for (var i = 0; i < fromList.length; i++)");
console.log("fromList.length = " + fromList.length);
    copyFromVar = fromList[i].value ;
console.log("copyFromVar = " + copyFromVar);
    intoList[i].innerHTML   = copyFromVar;
console.log("intoList[i].innerHTML = " + intoList[i].innerHTML);
} //

None of the console.log() statements work .

And the second alert() doesn't work .

Any idea why nothing works beyond the 1st alert() ? 


I'll Post the whole code if you wish .


Share this post

Link to post
Share on other sites

If not even that first console.log works then it sounds like it's not running at all.  If the first alert works but not console.log and not the second alert, maybe the browser that you're using does not have console.log defined.

Share this post

Link to post
Share on other sites

Oops yes , the first console.log() works , then no more .

I am running chrome .

Is there a way to turn  on/off console in all browsers ?

I am guessing it's always running .


Edited by vmars316

Share this post

Link to post
Share on other sites

I'm not sure if browsers have a way to disable the developer tools or the console specifically.  Probably not, because if so then any code that tries to use the console would be a fatal error and the code would stop running.

Share this post

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


  • Create New...