Results 1 to 5 of 5

Thread: The display and the code is inconsistent of ddlevelsmenu

  1. #1
    Join Date
    Nov 2011
    Posts
    5
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Question The display and the code is inconsistent of ddlevelsmenu

    1) Script Title: ddlevelsmenu

    2) Script URL (on DD): http://www.dynamicdrive.com/dynamicindex1/ddlevelsmenu/

    3) Describe problem:
    I use ddlevesmenu for selection in a thickbox which is called by ajax, when I change the input param, there comes a very confusing question.
    The content of the menu on the browse will not changed, but the param and the html code are correct, and the problem disappear after refreshing.

    And I have tried to clear it with
    jQuery('#myjquerymenu').html(""); & jQuery('#jquerymenu').innerHTML="";
    also
    setTimeout function

    but none of these are helpful,

    Could any one help me to solve it ?
    Thanks a lot !

  2. #2
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    Not sure what you're talking about. You can try .empty() or .remove()

    The first will empty the element, the second will remove it completely, example:

    Code:
    jQuery('#myjquerymenu').empty();
    or:

    Code:
    jQuery('#myjquerymenu').remove();
    Don't use remove if you need the element later. Well if the element gets recreated, then remove() can work out OK. But otherwise, stick with .empty()

    If you want more help:

    Please post a link to a page on your site that contains the problematic code so we can check it out.
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  3. #3
    Join Date
    Nov 2011
    Posts
    5
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default

    Code:
    function getContentItem(){
        var url = ...;
        var param = ...;
        var encodeUrl = encodeURL(url, param);
        ...
        jQuery.get(encodeUrl, function(data){
          jQuery('#myjquerymenu').html(data);
          jQuery('#myjquerymenu li>a').click(function(){
            attributeName = jQuery(this).attr("name");
            tempAttributeValue = jQuery(this).attr("id");
            attributeNameType = jQuery(this).attr("value");
            var textVal = jQuery(this).text().replace(/\s/g, " ");
            jQuery('#input').val("");
            jQuery('#attribute').val(textVal);
            jQuery('#operator').empty();
            jQuery('#operator').append('<option value=""><message key="content.inline.search.select.selectItem"/></option>');
            for (i = 0; i <![CDATA[ < ]]> temp[attributeNameType].length; i++) {
              var option = jQuery('<option></option>');
              option.val(i);
              option.text(temp[attributeNameType][i]);
              option.appendTo('#operator');
            }
            checkValue(attributeNameType, attributeName);
          });
          ddlevelsmenu.setup("myjquerymenu","topbar");
        })
        ...
      }
    These are the problematic code in my program.
    I have tried the .empty() and the .remove() already, still no help...
    The content of the myjquerymenu turns out to be right only after I refresh the page, it confuses me a lot...
    Last edited by jscheuer1; 11-07-2011 at 03:49 AM. Reason: Format

  4. #4
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    encodeURL is not a javascript function. Perhaps you have it defined elsewhere. But if your aim is to send get data to jQuery.get(), like ?something=somevalue, that should be done with the jQuery.get() syntax:

    Code:
    jQuery.get('somepage.php', 'something=somevalue', function(data){
     . . .
    });
    But seriously, it's very difficult to diagnose this without a link to the page.
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  5. The Following User Says Thank You to jscheuer1 For This Useful Post:

    Peggy_Z (11-07-2011)

  6. #5
    Join Date
    Nov 2011
    Posts
    5
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default

    I have figured it out.
    It seems that the ddsubmenu is not created inside the div myjquerymenu of the thickbox but in the main page,
    so I remove the ddsubmenu element each time I call the getContentItem() method with
    jQuery('#ddsubmenu1').remove()
    so the content can be recreated.

    I really appreciate your help,
    Thank YOU all the same.

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •