rviscomi / trunk8

jQuery Truncation Plugin -- THIS PROJECT IS NO LONGER MAINTAINED
MIT License
703 stars 95 forks source link

add trunk8_lines to element #43

Closed waitingmyself closed 10 years ago

waitingmyself commented 10 years ago

To set a different lines for element

rviscomi commented 10 years ago

The init method already takes an "options" object, which can have a "lines" property to overwrite the default setting.

waitingmyself commented 10 years ago

thanks for your reply,but if in one page, i have some elements with different lines to show , what should i do? like this?

$('.trunk8_1').trunk8();
$('.trunk8_2').trunk8({lines:2});

i have try to do like this :

$('.trunk8').trunk8({
        lines : $(this).attr('trunk8_lines') || 1
    });

but it not worked well

any other better way?

rviscomi commented 10 years ago

I guess it would make sense to support data attributes to configure trunk8 settings. If you'd like, submit a pull request to handle any data-trunk8-* attribute that will overwrite the corresponding setting. It should not take precedence over the options object in init. It should work for any setting name.

In lieu of that, the second approach looks like the best way to go.