Note that there are some explanatory texts on larger screens.

plurals
  1. POjQuery parent()
    primarykey
    data
    text
    <p>I need some help with parent() in jQuery.</p> <p>I have a list of images, each followed by a form, where the user can perform some actions, like changing the description of the image etc.</p> <pre><code>&lt;div id='items_list' class='items_list' &gt; &lt;div id='item_209' class='item_details' &gt; &lt;form action='actions_dispatch2.php' method='post' name='update_image_details' class='form'&gt; &lt;input name='originator' type='hidden' value='/list_images3.php' /&gt; &lt;input name='album_id' type='hidden' value='27' /&gt; &lt;input name='image_id' type='hidden' value='209' /&gt; &lt;input name='is_gallery' type='hidden' value='N' /&gt; &lt;input name='language' type='hidden' value='1' /&gt; &lt;div class='item_img'&gt; &lt;img src=' images/square_thumbnails_75x75/209.jpg'/&gt; &lt;/div&gt; &lt;!-- end div item_img --&gt; &lt;div class='item_description'&gt; &lt;h3&gt; title &lt;/h3&gt; &lt;h4&gt; some description...&lt;/h4&gt; &lt;/div&gt; &lt;!-- end div item_description --&gt; &lt;div class='item_buttons' parameters='&amp;album_id=27&amp;image_id=209&amp;is_gallery=N&amp;language=1&amp;originator=/list_images3.php'&gt; &lt;a href='/actions_dispatch2.php' action='modify_image' title='Modify' rel='#overlay'&gt; &lt;input name='modify_image' type='submit' value='modify' class='button' /&gt; &lt;/a&gt; &lt;/div&gt; &lt;!-- end div item_buttons --&gt; &lt;/form&gt; &lt;/div&gt; &lt;!-- end div item_details (for content to modify)--&gt; &lt;div id='item_208' class='item_details' &gt; &lt;!-- ...and it keeps going with another image... --&gt; </code></pre> <p>I also have a jQuery function that should retrieve some parameters to pass to action_dispatch2.php:</p> <pre><code>$(function() { // if the function argument is given to overlay, // it is assumed to be the onBeforeLoad event listener $("a[rel]").overlay({ onBeforeLoad: function() { // grab wrapper element inside content var wrap = this.getContent().find(".contentWrap"); // get page to load and action from href attribute in link var page_to_load = this.getTrigger().attr("href"); var action = this.getTrigger().attr("action"); //get parameters from field parameters in parent div (item_buttons) var parameters = this.getTrigger().parent().attr("parameters"); // load the page specified in the trigger wrap.load(page_to_load + "?action=" + action + parameters); } }); }); </code></pre> <p>Well i'm able to retrieve the href and action attributes, but can't retrieve parameters, which is in the parent()div. the variable parameters gets 'undefined' The strange thing is that I have another page, very similar (that one shows a list of albums), where i am able to retrieve that parameter ok!</p> <p>I don't know what the problem could be! can you point me in the right direction? I have firebug installed but don't know exactly how to use it to track that variable, if possible..</p> <p>thanks, patrick</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload