Say, I have a jquery plugin with default options that can be overridden just like any plugin.
What I want to do is add multiple default options that can be called via the options or somewhere in the plugin “trigger”.
Question is.. How?
Jsfiddle that sort of explains it further:
http://jsfiddle.net/A7LMc/
How this plugin works is completely irrelevant to the question.
Essentially something like this:
if ( option == 'b' ) {
var defaults = {
width: '260',
height: '120'
};
}
else {
var defaults = {
width: '60',
height: '10'
};
}
and then call it in the options something like this:
<script type="text/javascript">
$(document).ready(function() {
$('.boxes').b({
option: 'b',
width: '500'
});
});
</script>
To further elaborate:
This works but is not what I want:
http://jsfiddle.net/A7LMc/1/ ( in the js )
========
This doesn’t work and is more or less what I want:
http://jsfiddle.net/A7LMc/2/ (in the html )
..the reason why I said “more or less” is because.. well, it doesn’t work and I don’t really care how I can call it forth as long as it is in the plugin trigger code that is inside <script> tags and is simple.
Moved to the plugin: http://jsfiddle.net/A7LMc/3/
And then:
Otherwise why not do it inside the plugin?
Or you could do it as an array like this….