0

I am doing some "fancy" hiding (slideUp and slideDown) of elements on a Sharepoint WebPart.

I added another handler, though, for a button:

$(document).on("click", '[id$=btnAddFoapalRow]', function (e) {
    alert('you mashed the foapal button');
    if ($('[id$=foapalrow3]').css('display') == 'none') {
        $('[id$=foapalrow3]').slideDown();
    }
    else if ($(['id$ = foapalrow4]').css('display') == 'none') {
        $('[id$=foapalrow4]').slideDown();
    }
});

...but it not only fails to work (the HTMLTableRows do not display when the button is clicked), but the other jQuery (checkbox change event handlers, etc.) also fail to work after adding this code. Commenting it out, and the old code does work still.

Why would this code obliterate the whole shebang?

Ahsan
  • 2,488
  • 2
  • 22
  • 44
B. Clay Shannon-B. Crow Raven
  • 8,547
  • 144
  • 472
  • 862

2 Answers2

3

$(['id$ = foapalrow4]') <- seems like there is a typo here

it should be

$('[id$ = foapalrow4]')

your code after edit:

$(document).on("click", '[id$=btnAddFoapalRow]', function (e) {
    alert('you mashed the foapal button');
    if ($('[id$=foapalrow3]').css('display') == 'none') {
        $('[id$=foapalrow3]').slideDown();
    } else if ($('[id$ = foapalrow4]').css('display') == 'none') {
        $('[id$=foapalrow4]').slideDown();
    }
});
Mohamed-Yousef
  • 23,946
  • 3
  • 19
  • 28
timeiscoffee
  • 468
  • 3
  • 14
2

Presumably you must be working on visual studio if you are working with SharePoint. use a JavaScript error validating extension and avoid shooting yourself on the foot with typo's such as the one in your code in line 6 (See screenshot for the plugin that i use (JavaScript parser) in action that detects the JS error!

enter image description here

Ahsan
  • 2,488
  • 2
  • 22
  • 44