I think I have a "theory" about why this is happen and it might not be
jQuery related but just Javascript, but maybe someone can explain this
because it is so odd.

This is the code:

  logln("wcError "+IsHidden('wcError')?"hidden":"not hidden");

logln() is a function tha basically appends text to a log window.
However, I don't see

      "wcError hidden"  or  "wcError not hidden"

but rather:

      " hidden"  or  "not hidden"

in other words, the left side string "wcError " is not concentated.

But the following works:

  s = IsHidden('wcError')?"hidden":"not hidden"
  logln("wcError "+s);

or this by enclosing it with ()

  logln("wcError "+(IsHidden('wcError')?"":"not ")+"hidden");

but not this (without parenthesis)

 logln("wcError "+IsHidden('wcError')?"":"not "+"hidden");

IsHidden() just returns true or false

function IsHidden(s) {
   var e = document.getElementById(s);
   return !e?true:e.style.display != "block";
}

Anyway, logln() was first a jQuery method for my plugin and in trying
to see what is going I am made it strictly DOM so I see it isn't
jQuery related.

What am I missing here?  Something about how JS sees strings that I am
missing here.

In the same vain, I now see it is similar to a fix I had to make in
another project where I had a  table paging logic:

function $(v) { return(document.getElementById(v)); }
function gotoPrevPage()
{
  $("start").value -= 1*$("rows").value;    // <- WORKS AS EXPECTED
}

function gotoNextPageBUG()
{
  $("start").value += 1*$("rows").value;      // <- BUG!!
}

function gotoNextPageFIX()
{
  $("start").value -= -1*$("rows").value;   // <- FIX!!
}

I was multiplying by 1 to help JS type cast the operaton.  But that
didn't work went using the inclusive +=  operatoin.   Worked fine with
-= operation.   So I used the reverse logic to multiply by -1 instead
with -=.

To me,  that looks look like a JS bug?  No?

---
HLS

Reply via email to