php - iframe created twice with jquery -
i using 2 links on page create iframe each. problem is creating iframe twice.
i did use each link id check weather loading 1 iframe each link iframe loads twice has same id.
<a id="mylink12" href="anyurl">my link one</a> <a id="mylink13" href="somedifferenturl"> link two</a> jquery(".editme").click(function(event) { event.preventdefault(); var editid = 'frame-'+jquery(this).attr('id'); var url = jquery(this).attr('href'); if(jquery(editid).size() == 0) { jquery('<iframe />', { name: 'frame', id: editid, src: url }).appendto('#here'); }; return false; }).once();
not sure why.
the source of problem in line:
if(jquery(editid).size() == 0)
you have prepend editid
'#'
string if want find element id
attr. otherwise editid
treated tag name (frame-*
).
so line should changed to:
if(jquery('#'+editid).size() == 0)
Comments
Post a Comment