javascript - To trigger everytime with .click()? -
i tried have .click()
on <a>
find out wont trigger every time click, suppose open dialog.
that not problem need pass value jquery to. cant figure 1 out.
i need <a>
because it's gone in dropdown menu. got suggestions?
edit code use , workes
$(document).ready(function() { $('#dialog').dialog({ autoopen: false, bgiframe: true, modal: true, height: 600, width: 1000, close: function() { $(this).dialog('destroy'); } }); $('a').live('click', function(evt) { evt.preventdefault(); var ids = $(this).attr('id'); var first = "<iframe style='width: 100%; height: 100%;' src='" + "" + "'</iframe>'"; $('.iframe').html(ids); $('#dialog').dialog('open'); }); });
this code intilise dialog, open on every click , work every time, trick me here 'destroy' @ end , inilise
thanks guys help
this trigger on every click. whilst doubt case, check haven't got other event handlers listening on 'a', applying event.stopimmediatepropagation()
. try adding return false
end of click handler, or better:
$('a').click(function(evt) { var first = "<iframe style='width: 100%; height: 100%;' src='" + need put value here + "'</iframe>'"; $('.iframe').html(first); $('#dialog').dialog({ bgiframe: true, modal: true, height: 600, width: 1000 }); evt.preventdefault(); });
you might find page reloading if you're not preventing default action of anchor tag, give impression nothing happening.
what sort of "value" thinking of? can use jquery's data() store information, , of course have access global variables in scope.
edit: answer comment, can retrieve id of inside click event follows:
var theidofthea = $(this).attr('id');
note must placed inside handler.
edit2:
$('a').live('click', function(evt) { var first = "<iframe style='width: 100%; height: 100%;' src='" + $(this).attr('id') + "'</iframe>'"; $('.iframe').html(first); $('#dialog').dialog({ bgiframe: true, modal: true, height: 600, width: 1000 }); evt.preventdefault(); });
Comments
Post a Comment