Jump to content
  • 0

Функция


Str@nnik
 Share

Question

Здравствуйте! Подскажите, почему не работает данная функция? Точнее работает, но только для аргументов вида arg*10

mou.setMenu = function (num) {
$.get("/getform.php?menu=1", function(data) {
var dat = eval("(" + data + ")");
var count = dat[0];
var tMenu = dat[1];

var nMenu = 1;

while (nMenu <= count) {
$('#lmenu ul').html($('#lmenu ul').html() + '<li>'+ tMenu[nMenu][1] +'</li>');
if (/\*/.test(tMenu[nMenu][2])) {var arr = tMenu[nMenu][2].match(/(\D+)\*(\d+)/); $('#lmenu ul li:nth-of-type('+nMenu+')').click(function () {mou.display(arr[1], arr[2])}); }
else { $('#lmenu ul li:nth-of-type('+nMenu+')').click(function () {alert(123)}); }
nMenu++;
}

$('#lmenu ul li:nth-of-type(1)').css({borderRadius: '5px 5px 0 0', borderTop: 'none'}).click(function () {mou.display('main')});
});
}

Итак dat[0] - это количество записей всего. dat[1] - это массив. dat[1][0] - ид записи, dat[1][1] - его имя, dat[1][2] - обработчик.

Не работает именно это:

else { $('#lmenu ul li:nth-of-type('+nMenu+')').click(function () {alert(123)}); }

Уже просто интересно стало))) Провозился с этим около часа) Так и не смог решить эту задачу :D

Edited by Str@nnik
Link to comment
Share on other sites

1 answer to this question

Recommended Posts

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue. See more about our Guidelines and Privacy Policy