I use this plugin for dropdown menus: http://www.filamentgroup.com/lab/jquery_ipod_style_and_flyout_menus/
The button is inside the div as:
<div class="stuff"> some stuff <a class="quickfire">menu</a> </div>
I apply it to some link, for example:
jQuery('.quickfire').menu({ content: jQuery('#search-engines').html(), // grab content from this page showSpeed: 400 });
Where .quickfire is the name of the link class. So far, so good, it works.
However, the user can also initiate an AJAX call, which selects the HTML link from the server and replaces the βstuffβ div with new content (which itself will contain the quickfire link).
jQuery.ajax({ url: 'ajax_file.php', data: { action: 'create_option_new_version', id: jQuery('#qid').val(), div: jQuery("#addMoreOptions").parent().parent().attr('id'), cleanOutput: true }, success: function(data, textStatus, jqXHR){ jQuery(".stuff").html(data); } });
As expected, the quickfire link is no longer tied to jQuery Menu. So, I bind it every time:
jQuery.ajax({ url: 'ajax_file.php', data: { action: 'create_option_new_version', id: jQuery('#qid').val(), div: jQuery("#addMoreOptions").parent().parent().attr('id'), cleanOutput: true }, success: function(data, textStatus, jqXHR){ jQuery(".stuff").html(data); var position = jQuery('.quickfire').position(); console.log("left: " + position.left + " top: " + position.top); jQuery('.quickfire').menu({ content: jQuery('#search-engines').html(),
Almost there!
The problem is that when I click on the newly created quick launch button, it works, but the menu appears in the upper left corner of the screen, and not next to the button!
I tried to print the "position" of the quick launch button. For the initial load, one said 361 x 527. For subsequent ones, they all say that 0 x 320
Here is the real code:
jQuery("#addMoreOptions").live('click',function(){ jQuery(".lastPollOptionInput").removeClass("lastPollOptionInput"); jQuery.ajax({ url: 'ajax_file.php', data: { action: 'create_option_new_version', id: jQuery('#qid').val(), div: jQuery("#addMoreOptions").parent().parent().attr('id'), cleanOutput: true }, success: function(data, textStatus, jqXHR){ jQuery("#addMoreOptions").parent().parent().html(data); jQuery('.quickfire').fgmenu({ content: jQuery('#search-engines').html(),