How to - cHtml onclick event

Hi guys i’m new here currently learning the amazing world of Yii Framework. But i have a problem now…

I’m developing a script to just share a link on facebook but i need to open the link in a popup window when the user clic on it, instead of opening a new tab in the explorer. So how can i use window.open onclick event ?

This is my current working code opening in a new tab instead a popup.




<?php

$link = 'facebook.com/sharer/sharer.php?u=' . aUrl('/referral/catch',array('id' => app()->user->id));


echo CHtml::link($this->t('Share it on Facebook'),$link,

	array('target' => '_blank'));

?>



Any help here will be appreciated. Thanks !

Hi bro, remember you can use Ajax with JQuery and to make use of it for your objective… If I need to be more explicit just tell me, cause I’m not sure if you already get me… Keep communication that we can help you…good luck

Hi thank you for your reply, i got you, something like this is what you mean.


<div id="fb-root"></div>

<script>

window.fbAsyncInit = function() {

FB.init({appId: '10XXXX2XXXXXXX', status: true, cookie: true,

xfbml: true});

};

(function() {

var e = document.createElement('script'); e.async = true;

e.src = document.location.protocol +

'//connect.facebook.net/en_US/all.js';

document.getElementById('fb-root').appendChild(e);

}());

</script>


<script type="text/javascript">

$(document).ready(function(){

$('#share_button').click(function(e){

e.preventDefault();

FB.ui(

{

method: 'share',

href: ''

});

});

});

</script>


<img src = "share_button.png" id = "share_button">



But how can i pass custom parameters to Facebook share url (href) !?

It’s done reykel thank you for your suggestion to use ajax.

I passed the variables i need this way.




href: "<?php echo (aUrl('/referral/catch',array('id' => app()->user->id)));?>"



Thanks for your advice.