I have a strange problem with the jquery plugin and options getting over written.
-
If I setup the plugin like this it works fine.
$("#social-media").socialMedia({ url: "http://css-tricks.com", social: [ { name: "facebook", widget: "like_small" }, { name: "twitter", widget: "small" }, { name: "googlePlus", widget: "small" } ] }); -
If I add a extra option that I need to overwrite, the facebook like button does not load.
$("#social-media").socialMedia({ url: "http://css-tricks.com", social: [ { name: "facebook", widget: "like_small" }, { name: "twitter", widget: "small" }, { name: "googlePlus", widget: "small" } ], facebook: { id: 195838043798363 } });
By default,
jQuery.extend()replaces whole properties. So, if the defaults have this:And your options look like this:
The whole
facebookobject will be replaced with{ id: 195838043798363 }.It turns out that
jQuery.extend()supports doing what you’re trying to get it to do, if you passtrueas its first argument. Changing this line:to this:
Should make it do what you want it to do.