0

the way I have my portfolio setup is so that if a potential employer wants to see certain programming language, let's say PHP only, they tick the PHP box, and all the samples with PHP involved will show up (May it be from a CMS, or just straight up PHP)

Here is the page in question

http://evanparsons.net/samples.aspx

It sort of works now, however if I want to see just AJAX samples, only one shows up rather than the three in total that I have. If I could somehow change the fade in to have a !important on it, I think this would work

I am targeting it as a class, so for some reason .attr and .css don't work, however opacity works. I just can't set !important in the display attribute.

0

2 Answers 2

2

In the example you've shown, the only Ajax sample it shows when you click Ajax is the one that has the class 'Ajax' which is 'Shared Event Calendar module for Silverstripe 2.4'

You've only got one other ajax sample which has the class AJAX which won't match because it's not a string match with Ajax

AJAX != Ajax

So your jquery selector won't work because it's case sensitive. Also I can only see 2 samples, not 3 ?

edit: Also, in your JS that wires up your sample checks, it might be better to use

$('.samples :checkbox').each(function () {

rather than

$(':checkbox').each(function () {

as it limits the scope that jquery has to iterate.

Edit:

To explain why some samples are being hidden, it's because of how your

$(':checkbox').each(...)

Is working;

Check controls fires every time you click something and it processes all the checkboxes that can be clicked. Imagine if your experience looked like this:

<div class='samples'>
    <div class='asp'>...</div>
    <div class='php asp'>...</div>
    <div class='php django'>
</div>

If you click the ASP checkbox, it'll loop through and say, ok show sample 1 because it's got ASP in it, then it'll loop and say show sample 2 because its got ASP in it, then it'll loop once more and see that sample 3 doesn't have ASP in it, so it will hide it.

Then it loops to the next check box (for sake of argument called PHP); it starts at sample 2 (because of the .each loop) and see that it's not checked so it hides the sample 2 even though it was shown before, and same for sample 3.

Do you see what I mean ? the subsequent .each iterations are cancelling out the displays that are done for the checked box; when the ID of the checkbox you selected appears before the actual sample in the HTML layout.

Sign up to request clarification or add additional context in comments.

4 Comments

Hey, that was just an example but if you choose just Javascript, my AJAX/JSON Photo Gallery sample doesn't appear. I believe it's being cancelled out from AJAX samples not being displayed.
I'll update my answer to explain why this is happening, give me a minute or so...
A possible way to solve this is to hide all samples when CheckControl fires first; then only use this selector $('input:checkbox:checked') and then only make those matches visible; don't use the else clause at all! only potential issue is when hiding it might make the page pop, you might need to use a fast animation to close all $('input:checkbox') divs first.
GOT IT! You're the man! Also, I knew what was making the issue, I was just having a hard time correcting it :P Thanks very much, your solution was very clean.
2

You have one of your divs listed under the class "AJAX" instead of "Ajax". Changing that fixed it for me.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.