|
You can not catch anonymous functions like that in the debugger. If you want to step through it, you need to extract it into a named function.
function ReadXml(xml) {
var configNodes = $(xml).find('Config');
parseConfigNodes(configNodes);
var imageNodes = $(xml).find('Images');
parseImages(imageNodes);
var dataNodes = $(xml).find('Data');
parseData(dataNodes);
}
$.ajax(
{
type: "GET",
url: _cfgDataFile,
dataType: "xml",
success: ReadXml(xml);
});
|
|
|
|
|
I tried it that way too.
When I switched to IE, it was fine.
".45 ACP - because shooting twice is just silly" - JSOP, 2010 ----- You can never have too much ammo - unless you're swimming, or on fire. - JSOP, 2010 ----- "Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass." - Dale Earnhardt, 1997
|
|
|
|
|
You mean IE allows you to step into anonymous functions like the original example?
|
|
|
|
|
Yes
".45 ACP - because shooting twice is just silly" - JSOP, 2010 ----- You can never have too much ammo - unless you're swimming, or on fire. - JSOP, 2010 ----- "Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass." - Dale Earnhardt, 1997
|
|
|
|
|
Hi, i'm having some problems.
I have a parent div, which i want to add elements that raise click event.
i'm running with a for loop on the items.
$ParentObject = $("")
for (var i=0;i<10;i++)
{
$ChildObject = $("");
$ChildObject .click(function(){func(i);})
$ParentObject.append(ChildObject);
}
the problem is that on every child object that i click i get the 10 value,
how can i solve this problem?
thanks, ofer.
|
|
|
|
|
The function you've passed to the .click method has captured a reference to the variable, not the value of the variable. The usual C# approach of creating a copy of the variable within the loop won't work, since JavaScript variables are function-scoped.
Try something like this:
var handlerFactory = function(tmp){ return function() { func(tmp); } };
$ParentObject = $("<div id=\"Parent\"></div>");
for (var i=0; i < 10; i++)
{
$ChildObject = $("<div id=\"child" + i + "\"></div>");
$ChildObject .click(handlerFactory(i));
$ParentObject.append($ChildObject);
}
(Based on this SO answer[^].)
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
|
Can you please delete my membership?
modified 18-May-13 8:57am.
|
|
|
|
|
Shouldn't you ask for it in English.
|
|
|
|
|
Turkish or English what's the difference? Should do a little bit of artistic windows in Java language..
var lucky = [];
var iPlay = 0;
do{
var taken = new Array(49);
for (var j=49; j>0; j--) taken = false;
var rand = Math.round(49 * Math.random());
if(!taken[rand]){
lucky[iPlay] = rand;
taken = true;
iPlay++;
}
}while(iPlay < 6);
}
can picks same number/s inside of column can you please take care of some these codes above..
|
|
|
|
|
Hakan Bulut wrote: Turkish or English what's the difference?
|
|
|
|
|
|
Hi,
My requirement is to show long message in pop up or ALT with scroll bar when I click on read more or mouse over on readmore text.
I was thinking to show in div. When user click or mouse over on readmore text then the hidden div should show up and display the message. Is there any other better way to show?
Second, I want to give speaking type design to div with scroll bar. Does any one have code to do this?
Third, How to show small scroll-bar in div like we have in chat box of facebook.
Thanks in advance,
Inder...
|
|
|
|
|
Hi,
I need to display long message in a pop up on click or mouse over of read more. What are the possible ways to show message without opening in the another window.
I was thinking to show in ALT or open a hide div on mouse over or click of read more. Any other way to do this?
Second, if I use div then I want to show div in speaking design with tinny scroll-bar. please let me know how to do this? or please share code.
Thanks in advance,
Inder...
|
|
|
|
|
I would recommend searching for jquery plugins to do jquery dialogs. There are some nice plugins that will show dialogs for you and already have the code done.
There are only 10 types of people in the world, those who understand binary and those who don't.
|
|
|
|
|
hi to all
i have an asp drop down and i want to access datasource in javascript
how can i do this?
like this code in c#
myDropDown.DataSource=mydatatable;
|
|
|
|
|
there is no concept of the datasource in javascript. your asp dropdown is rendered as an html select which is containing one or more option elements.
example:
<select>
<option value="index1">Some Display Info</option>
<option value="index2">Some More Display Info</option>
</select>
The code that you listed:
mehdi.sabet wrote: myDropDown.DataSource=mydatatable;
is run server side where that HTML gets rendered and sent down to the clients browsers where it will be visually rendered for the user(s) to see. if you want access to all of the items in the dropdown you will have to get the select element and then iterate through its children.
as if the facebook, twitter and message boards weren't enough - blogged
|
|
|
|
|
If database is Access .mdb you could use this ^ or SQL db this ^
|
|
|
|
|
dusty_dex wrote: If database is Access .mdb
a web site built on Access??
as if the facebook, twitter and message boards weren't enough - blogged
|
|
|
|
|
The OP didn't state why or where they are running Javascript.
You can't assume it's always javascript for server side.
I sometimes use the JS Access version for HTML Applications, which provide self contained solutions and nary a web server in site. Totally portable in one simple zip file.
|
|
|
|
|
I have a bad taste for Access. probably after seeing too many terrible Access Basic deployed apps.
as if the facebook, twitter and message boards weren't enough - blogged
|
|
|
|
|
dusty_dex wrote: The OP didn't state why or where they are running Javascript.
He did when he said it was an asp:dropdown meaning that the control is being rendered server side.
as if the facebook, twitter and message boards weren't enough - blogged
|
|
|
|
|
|
<!doctype html>
<html>
<head>
<title></title>
<style>
.cards
{
background-color: blue;
height: 100px;
width: 75px;
margin: 20px;
float: left;
border: 2px solid orange;
border-radius: 7px;
}
</style>
</head>
<body>
<div class="cards"id="ace1"spades></div>
<div class="cards"id="king1"spades></div>
<div class="cards"id="queen1"spades></div>
<div class="cards"id="jack1"spades></div>
<div class="cards"id="ten1"spades></div>
<div class="cards"id="nine1"spades></div>
<div class="cards"id="ace2"hearts></div>
<div class="cards"id="king2"hearts></div>
<div class="cards"id="queen2"heart></div>
<div class="cards"id="jack2"heart></div>
<div class="cards"id="ten2"hearts></div>
<div class="cards"id="nine2"hearts></div>
<script type="text/javascript">
var cards = document.querySelector(".cards");
cards.addEventListener("click", card, false);
function card()
{
console.log("hello world");
}
</script>
</body>
</html>
|
|
|
|
|
because you are trying to add it into a collection of objects.
You can only use addEventListener on a target element, document or window. If you want to use a collection like this then you will have to loop through them and call the addEventListener for each.
also just an FYI but this won't work in IE8 either way.
this is just another reason to use a framework like jQuery because it abstracts this away for you. Even the IE8 issue so long as you aren't using jQuery 2.x.
as if the facebook, twitter and message boards weren't enough - blogged
|
|
|
|