Вы действительно должны использовать pow (число, мощность) ;. К сожалению, караты не работают как силовой знак в C. Много раз, если вы не можете что-то сделать с другого языка, это потому, что для вас есть различная функция, которая делает это для вас.
Сделайте шаг за шагом. Вам нужно создать экземпляр нового экземпляра nicEditor для каждого вновь добавленного элемента управления.
//Create the text area first and append it to DOM.
var elm = $('<TEXTAREA NAME="description[]" id="test" ></TEXTAREA><a href="#" id="remScnt">Remove</a>').appendTo(scntDiv);
// Instantiate the nicEditor Instance on it. It will now have the reference of the element in DOM.
new nicEditor().panelInstance(elm[0]);
//wrap it with p
elm.wrap($('<p/>')); //You can chain it in the first step itself after appendTo(scntDiv).
$(document).on('click', '#addScnt', function () {
// Add the textarea to DOM
var elm = $('<textarea NAME="description[]"></textarea>').appendTo(scntDiv);
//Get the current SIZE of textArea
var curSize = $('textarea[name="description[]"]').length;
//Set the Object with the index as key and reference for removel
editors[curSize] = new nicEditor().panelInstance(elm[0]);
//Create anchor Tag with rel attribute as that of the index of corresponding editor
elm.after($('<a/>', {
rel: curSize,
'class': "remScnt",
text: "Remove",
href: '#'
})).next().andSelf().wrapAll($('<p/>')); //add it to DOM and wrap this and the textarea in p
});
$(document).on('click', '.remScnt', function (e) {
e.preventDefault();
//Get the textarea of the respective anchor
var elem = $(this).prev('textarea');
//get the key from rel attribute of the anchor
var index = this.rel;
//Use it to get the instace and remove
editors[index].removeInstance(elem[0]);
//delete the property from object
delete editors[index];
//remove the element.
$(this).closest('p').remove();
});
Примечание live()
устарела и прекращена в более новой версии, поэтому используйте on()
с делением событий для динамически создаваемых элементов. Также измените идентификатор на класс для ссылки удаления .remScnt
, поскольку дублирующийся идентификатор может вызвать проблемы и сделать html недействительным