Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

No values received #1

Open
camilopez opened this issue Oct 15, 2010 · 2 comments
Open

No values received #1

camilopez opened this issue Oct 15, 2010 · 2 comments

Comments

@camilopez
Copy link

Is the plugin working at all? Im trying the demo and the results I received is: “}” with no values.
Then I am trying it in local and I recevied same value “}”, and it doesnt matter if I have selected some items or not.
Im checking the variable fcbklist_values and always has the value “}”
Could anyone help me?
Thanks!!

@michaelv
Copy link

Hi,

I experienced some problems with the plugin myself: when you submit the form, all the items in the list were posted, whether or not you selected some.
For those who want this to work, I created a little workaround: when the button in the form is clicked, all hidden input fields of the items that are not selected are removed. As a result, only the items you select will be posted.

HTH!

Best regards,
Michael

(warning, there is PHP code in here, you probably want to remove this ;))

    <script type="text/javascript">
        $(document).ready(function() {
            $(".fbfriendids").hide();
            //id(ul id),width,height(element height),row(elements in row)
            $.fcbkListSelection("#fcbklist","400","50","2");
            $("#next").click(function() {
                $('#fcbklist').children().each(function(i,listEl){
                    if(!$(listEl).hasClass("liselected")) {
                        // item is not selected, so uncheck the checkbox
                        $(listEl).find("input").attr('checked', false);
                    } else {
                        $(listEl).find("input").attr('checked', true);
                    }
                });
                $("#fbform").submit();
            });
    // setup form validation so that at least 1 friend needs to be selected
            jQuery.validator.addMethod("facebookfriendsrequired", function(value, element) {
                var fbFriendsValid=false;
                $('#fcbklist').children().each(function(i,listEl){
                    if($(listEl).hasClass("liselected")) {
                        fbFriendsValid = true;
                    }
                });
                return fbFriendsValid;
            }, "Please select at least 1 friend.");
            $("#invitefacebookfriends").validate({
                invalidHandler: function(form,validator) {
                    var errors = validator.numberOfInvalids();
                    if (errors) {
                        $(".errorSpan").show().html("Please select at least 1 friend.");
                    } else {
                        $(".errorSpan").hide();
                    }
                }
            });
        });
    </script>
<span id="errorSpan" class="errorSpan"></span>
    <form action="test.php" method="post" id="fbform">
        <ul id="fcbklist">
            <?php foreach($friends as $friend) { ?>
                <li>
                    <img src="https://graph.facebook.com/<?php echo $friend['id']; ?>/picture"/><strong><?php echo $friend['name'];?></strong><br />
                    <input type="checkbox" name="friendids[]" class="facebookfriendsrequired fbfriendids" value="<?php echo $friend['id'];?>" />
                </li>
            <?php } ?>
        </ul>
        <input type="button" name="next" id="next"/>
    </form>

@rfanjul
Copy link

rfanjul commented Jan 3, 2012

It for the version that you are using of jquery, fcbkListSelection need 1.2.x if you put other up dosen't work.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants