I want to parse a string for a Node object. The following function should do something like this:
I want to get an input element built into the li tag, in which the input element can be a radio button or just a button. If the type is specified as a radio, you must add a shortcut.
Unfortunately, the part:
inputElement = $.parseHTML(this.getFullHtmlTextOf(inputElement) + labelElement);
not executed.
this.getKeyValAsInputInLiWithType = function (key, val, isArgument, type, isChecked) { var liElement, inputElement, labelElement; liElement = document.createElement('li'); liElement.setAttribute('id', 'li_' + key); inputElement = document.createElement('input'); inputElement.setAttribute('id', key); inputElement.setAttribute('type', type); inputElement.setAttribute('value', val); inputElement.setAttribute('data-dismiss', 'modal'); // additional attributes for a button if (type === 'button') { inputElement.setAttribute('class', 'button button-block btn btn-primary btn-default btn-discussion'); } // additional attributes for a radio button if (type === 'radio') { if (isChecked) { inputElement.setAttribute('checked', ''); } // adding label for the value labelElement = '\<label for="' + key + '"\>' + val + '\</label\>'; inputElement = $.parseHTML(this.getFullHtmlTextOf(inputElement) + labelElement); } if (key === addStatementButtonId) { inputElement.setAttribute('onclick', "$('#'+addArgumentContainerId).show();$('#'+addStatementButtonId).disable = true;"); } else if (type === 'button') { if (isArgument) { inputElement.setAttribute('onclick', "new InteractionHandler().argumentButtonWasClicked(this.id, this.value);"); } else { inputElement.setAttribute('onclick', "new InteractionHandler().positionButtonWasClicked(this.id, this.value);"); } } alert(this.getFullHtmlTextOf(inputElement)); liElement.appendChild(inputElement); return liElement; };
Yours faithfully,
Tobias
source share