-1

Is this possible?

I've got this HTML:

<div id='fbLike' class="fb-like" data-href="http://www.google.se" data-send="false" data-layout="button_count" data-width="100" data-show-faces="false" data-font="tahoma">

and this Jquery:

 $('#fbLike').attr('data-href',item_Url)

It seems it won't change when I fire that function, any ideas anyone?

Tomerikoo
  • 18,379
  • 16
  • 47
  • 61
Kim
  • 1,128
  • 6
  • 21
  • 41
  • I sense we don't have the full picture, here. 1) when are you changing the data-href, and 2) what code relies on the data-href being changed that seems to be missing the change, and 3) when/where are you making the change? If you are trying to change it before the DOM is ready, for example, that's one problem. If you are trying to change it after some other function has already scanned the unchanged DOM (and thereby stored away the original data-href value) that is another problem. This just seems like too little information to provide a solid answer... – Jason M. Batchelor May 28 '13 at 13:35
  • I'm trying to change the data-href on a click-function After the like-button has been created (but hidden). It seems it is just ignoring every action I'm trying to do, get a better picture now? :) – Kim May 28 '13 at 13:45
  • @mori57 It actually seems like it changes the data-href but the Like-button is loaded before so it doesn't make any sense, do you know how it's possible to "reload" the like-button on click? – Kim May 28 '13 at 13:52
  • AH! ... Ok, that's what I kind of suspected. I don't know. I'd suggest you look at FB's API documentation, and check there, as I'm unfamiliar with exactly how they do their "magic". I would imagine there should be a way to refresh it, but I can't say specifically, unfortunately. – Jason M. Batchelor May 28 '13 at 13:53
  • 1
    I actually found a good answer here: http://stackoverflow.com/questions/2764129/update-fblike-url-dynamically-using-javascript – Kim May 28 '13 at 13:57

2 Answers2

0

Try

$('#fbLike').data('href', item_Url)

Also see

http://api.jquery.com/jQuery.data/

connectedsoftware
  • 6,987
  • 3
  • 28
  • 43
0

Use:

$('#fbLike').data('href',item_Url);
Morfie
  • 670
  • 1
  • 7
  • 13