3

I would like to cancel an exposed element and expose another one in one onClick(). Is that possible? My code doesn't work.. Here's the js:

function tutStep1(){
    jQuery('#workspace_menu').expose({
        onLoad: function(event) {
            jQuery('.next').fadeIn();
        }
    });

    jQuery('.tutorial .next').click(function() {
        jQuery.mask.close();
        tutStep2();
    });
});

function tutStep2(){
    jQuery('.action_list').expose();
}

Here's the html

<span onclick="tutStep1();" >tutorial</span>

The mask just won't open again unless I click on the span. Or is there another way by not closing the mask, and switch elements to expose?

Derek 朕會功夫
  • 92,235
  • 44
  • 185
  • 247
Aileen
  • 53
  • 7

2 Answers2

1

Probably not a good idea to put a click event inside a click event. I'm not familiar with this mask plugin, but speaking in the abstract, you can clean it up by doing something like this:

$('.open').click(function() {
   $('#workspace_menu').show();
});

$('.tutorial, .next').click(function() {
   $('.mask').hide();
   $('.action_list').show();
});

Make sure you separate multiple selectors with a comma in the case of .tutorial and .next

Daniel Bernhard
  • 382
  • 3
  • 11
  • Hi, I actually used the first click as an onclick in the html tag, I changed the code, is this okay? – Aileen Jul 30 '13 at 04:46
  • It's bad practice nowadays to do this but even then it still won't work. If you hide the second click event inside the first function, it won't get called when you trigger the first click. – Daniel Bernhard Jul 30 '13 at 13:27
1

You have your onClick events nested inside one another. Recode and keep them all separate.

drew
  • 140
  • 1
  • 9