i would like to pass a variable into my javascript, using simple modal plugin, http://www.ericmmartin.com/projects/simplemodal/ , .click function in my view (html) ... how this is my javascript:
$('#basic-modal .basic').click(function (e) {
var src = "http://365.ericmmartin.com/"
$.modal('<iframe src="' + src + '" height="450" width="830" style="border:0">', {
closeHTML:"",
containerCss:{
backgroundColor:"#fff",
borderColor:"#fff",
height:450,
padding:0,
width:830
},
overlayClose:true
});
return false;
});
and here is what i tried in my html:
%a.basic{:href => "#", :onclick => 'var src = "http://somesite.com/"'}
Jquery Dialog has this exact functionality already built for you. I would highly recommend you try out this approach:
Using $(this).attr("friendid") makes it work:
$('#basic-modal .basic').click(function (e) {
$.modal('<iframe src="' + $(this).attr("friendid") + '" height="474" width="532" style="border:0;" scrolling="no">', {
closeHTML:"",
containerCss:{
},
overlayClose:true
});
return false;
And in the HTML create an attribute called "friendid" or whatever you want.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.