Jquery selectbox update breaks type in ability - Cannot read property 'apply' of undefined

Tuesday, November 3, 2015

I have the following jquery function that deploys a select box. Prior to updating it (to version 0.2), the option value="-1" resulted in removal of the value and insertion of a cursor with the ability to type in a new value. Since updating the selectbox to version 0.2.min.js, it no longer allows me to type in a value. It just puts the current value, which is "Add new value". Chrome reports an "Uncaught TypeError: Cannot read property 'apply' of undefined".



Even though .live is working in many other places on my site, I tried replacing it with .on because the first commenter below indicated .live is deprecated. That did not work.



Here is the jquery function.



$('.striation-value-select').live('change', function() {
var container = $(this).closest('.striations');
var val = $(this).val();
if (val == -1) {
var name = $(this).attr('name');
$(this).selectbox('destroy').remove();

container.find('#striation-value')
.removeAttr('style')
.attr('name', name)
.focus();
container.find('#striation-id').val('');
} else {
container.find('#striation-id').val(val);
}
});

0 comments:

Post a Comment