View Full Version : The display and the code is inconsistent of ddlevelsmenu

11-04-2011, 07:05 AM
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="";
setTimeout function

but none of these are helpful,

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

11-04-2011, 07:24 AM
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:




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.

11-07-2011, 03:22 AM
function getContentItem(){
var url = ...;
var param = ...;
var encodeUrl = encodeURL(url, param);
jQuery.get(encodeUrl, function(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('#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>');
checkValue(attributeNameType, attributeName);

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...

11-07-2011, 04:14 AM
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:

jQuery.get('somepage.php', 'something=somevalue', function(data){
. . .

But seriously, it's very difficult to diagnose this without a link to the page.

11-07-2011, 06:04 AM
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
so the content can be recreated.

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