jQuery - expected identity or string
I fårexpected identity or string o开发者_开发问答n the "if (vContains (gMouseoverBox) == true) (" to What is the reason for this?
var pProjectID = "static";
var gMouseoverBox = pProjectID + "_IF";
var arrBoxesNotMouseOvered = [];
function vContains(pName) {
for (var i = 0; i < arrBoxesNotMouseOvered.length; i++) {
if (arrBoxesNotMouseOvered[i] == pName) {
arrBoxesNotMouseOvered[i] = null;
return true;
}
}
return false;
}
function PopulateTooltipSuccess(pResponse) {
$('#' + gMouseoverBox).tooltip({
if( vContains(gMouseoverBox) == true ) {
var elem = document.getElementById(gMouseoverBox);
var coord = { clientX: getElementLeft(gMouseoverBox)+1, clientY: getElementTop(gMouseoverBox)+1 }; //coordinates doesn't work perfecly in IE but does in Firefox
$('#' + gMouseoverBox).simulate("mouseover", coord);
$(this).oneTime(2000, function() {
$('#' + gMouseoverBox).simulate("mouseout", coord);
});
}
})
}
I'm not entirely sure what you are asking. Maybe you could edit your question to be a bit clearer?
From your code, I can see the following:
- Can you post the accompanying html? Do you have an element with id "static_IF" ?
- Your arrBoxesNotMouseOvered is not populated. I'm guessing this happens elsewhere? Maybe we could see this code.
- You never use the variable
elem
(and your doing a document.getElementById() instead of a jQuery selection - You do $('#' + gMouseoverBox) and $(this). These should be the same.
- $gMouseoverBox.tooltip({ - Do you mean to seocify an anonymous function here? See code below:
Suggest the following code instead:
function PopulateTooltipSuccess(pResponse) {
var $gMouseoverBox = $('#' + gMouseoverBox);
$gMouseoverBox.tooltip(function(){
if( vContains(gMouseoverBox) == true ) {
var coord = {
clientX: getElementLeft(gMouseoverBox)+1,
clientY: getElementTop(gMouseoverBox)+1
}; //coordinates doesn't work perfecly in IE but does in Firefox
$gMouseoverBox.simulate("mouseover", coord);
$gMouseoverBox.oneTime(2000, function() {
$gMouseoverBox.simulate("mouseout", coord);
});
}
});
}
Without understanding exactly what you're trying the achieve that's all I can say at the moment.
精彩评论