JQ Mix Mouseover/Click Events & Switch Alt


I posted http://centerproto.zapto.org/mouse and http://centerproto.zapto.org/click. I have 7 items in a table that access php data via .load(). When I mouseover a cell the data is shown. In the ‘click’ version, I have to click to get the data. What I want is for mouseover to work until I click and then have mouseover disabled until I click again. Also, I’d like an alternative to switch() on a certain block of code. I’ve posted these questions at the relevant place in the ‘mouse’ source code. Please take a look! Thanks!

Regarded the switch:
you should be able to use this code instead of whole switch block. I didn’t test it though.


$j('#msg').load('demofile.php #' + c);
or (not sure if space makes any difference in your code, I would think it should be without space)
$j('#msg').load('demofile[COLOR="Red"].php#[/COLOR]' + c);

for click/mouseover issue: I would add data to element, like “clicked”, which set to true if it’s clicked, and check for that data value on mouseover event. Alternatively, you can remove mouseover and add it again, but it looks like too much hassle.

I didn’t have time to check anything of said adove in your code, so let me know if anything is unclear, or not working.

This sounds what you want as far as mouseover/click events go. Mouseover will work until you click, then it will not work until you click again.

var $td = $('td');
var clicked = false;

function myMouseOverFunc(e){
    alert('you moused over');
}

$td.bind('mouseover', myMouseOverFunc).bind('click', function(){
    if(!clicked){
        alert('you clicked it, now mouseover will not work on any tds!');
        $td.unbind('mouseover');
        clicked = true;
    }
    else {
        alert('you clicked it again, mouseover will work again!');
        $td.bind('mouseover', myMouseOverFunc);
        clicked = false;
    }
});

Have tried for 2 days to incorporate your suggestions. Had no luck. Tried many combos for the switch problem. And spent lots of time on the click/mouseover problem. Don’t think that bind can work in my case. Am thinking of another approach. Thanks for your time and effort!