0

i have a php code in a div. I'd like to cancel clicking on that div, until the page loads.

i'm having the problem if i click on the div too fast which calls a popup div... it doesn't get the content from the php.. so it is a blank popup div.

2
Contributors
3
Replies
4
Views
7 Years
Discussion Span
Last Post by scrappedcola
0

You could wait to attach the click event listener on that div until the dom is finished loading. If you use jQuery you would set up in a javascript block

<script>
$(document).ready(function(){
  $(#yourDiv).click(function(){ 
    /* fire popup */
  });
});
</script>
0

i tried below but now the onclick is not working. I want the function ShowContent only be able to run when the document(php) has loaded.

$(document).ready(function(){
  $("block").click(
					
					function ShowContent(d) {
if(d.length < 1) { return; }
var dd = document.getElementById(d);

AssignPosition(dd);

dd.style.display = "block";

}
					
					
					);
});
0

So the div you are attaching the click event to has the id = "block"? To attach the event to block you need to use

$("#block").click(function(){});

Also where is the parameter 'd' coming from? If you don't declare d be fore the click event it will be null. Try having d as a value on the div that as you are clicking and use

$("#block").click(function(){
 var d = this.getAttribute("d");
 var dd = document.getElementById(d);
AssignPosition(dd);
dd.style.display = ""; /* don't need to declare it block */
});
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.