javascript - Access the attributes of the caller element in the options section of the jQuery plugin -
i have links according show when clicked have different width , height data (this links generated in server side) like:
<a class="inline" href="#inline-content-1" data-width="80%" data-height="80%">content 1</a> <a class="inline" href="#inline-content-2" data-width="50%" data-height="80%">content 2</a>
now want use like:
$('.inline').colorbox({inline:true, width:$(this).data('width'), height:$(this).data('height')});
but $(this).data('width')
not seem valid in options section
colorbox can passed function evaluated in place of static value of properties.
$('.inline').colorbox({ inline: true, width: function(){ return $(this).data('width'); }, height: function(){ return $(this).data('height'); } });
Comments
Post a Comment