Jump to content

Update page dynamically ?


vmars316

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

Thanks 

 

 

 

 

Link to comment
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.

Link to comment
Share on other sites

Thanks Ingolme

dragElement(MyNewDiv);

Works great .

I have another problem , same program: 

in here:


<script>
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);
  }
} //
</script> 

None of the console.log() statements work .

And the second alert() doesn't work .

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

Thanks

I'll Post the whole code if you wish .

 

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...