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

slicePoint option not working #30

Closed
S0VIET opened this issue Mar 14, 2012 · 5 comments
Closed

slicePoint option not working #30

S0VIET opened this issue Mar 14, 2012 · 5 comments

Comments

@S0VIET
Copy link

S0VIET commented Mar 14, 2012

Hi, When I try to set the option slicePoice to something other than the default, it doesn't work and cuts off at the default 100chars, here's my JS:

    <script type="text/javascript">
            $(document).ready(function() {
            $('dl.expander dd:eq(0)').expander();
            $('dl.expander dd:gt(0)').expander({
            preserveWords: true,
            slicePoint: 200,
            collapseTimer: 0,
            userCollapse: true,
            beforeExpand: function() {
              $(this).parent().parent().append('<div class="success">before expand.</div>');
            },
            afterExpand: function() {
              $(this).parent().parent().append('<div class="success">after expand.</div>');
            },
            onCollapse: function(byUser) {
              var by = byUser ? 'user' : 'timer';
              $(this).parent().parent().append('<div class="success">on collapse (' + by + ').</div>');
            }
          });
        });
    </script>

Thanks.

@kswedberg
Copy link
Owner

I can't reproduce the problem you're seeing ( http://plugins.learningjquery.com/expander/test/?single%20block%3A%20slicePoint%20200%2C%20without%20preserving%20word%20boundaries )

would you mind putting together a reduced test case that shows the problem so I can take a look at what's going on? something on http://jsfiddle.net or http://jsbin.com would be ideal.

thanks!

@S0VIET
Copy link
Author

S0VIET commented Mar 18, 2012

jsfiddle wasn't working too well so I copied the source and made it work on this:

http://205.185.127.183/~soviet/test.html

As you can see, the first entry cuts off at 100 chars, and the second cuts off at the desired 200 chars.

@kswedberg
Copy link
Owner

That's right. It's working exactly as you are instructing it to work. The first entry cuts off at 100 characters because you have called .expander() without any options and 100 characters is the default:
$('dl.expander dd:eq(0)').expander();

The second one cuts off at 200 characters because you are calling .expander() with a bunch of options (including slicePoint: 200) for every <dd> element greater than index 0 (all but the first, or ... :gt(0)):

$('dl.expander dd:gt(0)').expander({
        preserveWords: true,
        slicePoint: 200,
       // etc. 
  });

If you want all of them to act the same way, just remove the first call — the one without the options — and change the selector of the second to include all of the <dd> elements:

$('dl.expander dd').expander({ // your options go here });

@S0VIET
Copy link
Author

S0VIET commented Mar 18, 2012

Thank you, that solved my problem. I'm not very good with Javascript as I haven't had the need to work with it's code excessively.

@kswedberg
Copy link
Owner

No problem. Glad you were able to get it working.

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

2 participants