javascript - Issue with custom capitalize String method, jQuery and Select2 -
i getting trouble jquery , select2.
i created function string prototype capitalize it. on other hand, using jquery 1.11.0 , select2 3.4.5 , when click on select2, got error because capitalize method called on non-string object:
unable capitalize non-string value.
<div id="select2-drop" class="select2-drop select2-display-none select2-with-searchbox select2-drop-auto-width" style="left: 813.5px; width: 380px; top: 777px; bottom: auto;">
printstacktrace.implementation.prototype.createexception@http://my.domain.com/js/stacktrace.js:56 printstacktrace.implementation.prototype.run@http://my.domain.com/js/stacktrace.js:43 printstacktrace@http://my.domain.com/js/stacktrace.js:30 string.prototype.capitalize@http://my.domain.com/js/orpheus.js:101 jquery.access@http://my.domain.com/js/jquery.js:4122 jquery.access@http://my.domain.com/js/jquery.js:4094 .css@http://my.domain.com/js/jquery.js:6911 abstractselect2<.positiondropdown@http://my.domain.com/js/select2/select2.js:1231 abstractselect2<.opening@http://my.domain.com/js/select2/select2.js:1322 singleselect2<.opening@http://my.domain.com/js/select2/select2.js:1840 abstractselect2<.open@http://my.domain.com/js/select2/select2.js:1265 singleselect2<.initcontainer/<@http://my.domain.com/js/select2/select2.js:2039 abstractselect2<.bind/<@http://my.domain.com/js/select2/select2.js:651 jquery.event.dispatch@http://my.domain.com/js/jquery.js:4624 jquery.event.add/elemdata.handle@http://my.domain.com/js/jquery.js:4292
i got stacktrace stacktrace.js lib. orpheus.js js file containing capitalize method (modified tests):
string.prototype.capitalize = function () { if( typeof != "string" ) { console.log("unable capitalize non-string value."); console.log(this); console.log(printstacktrace().join("\n")); return this; } return this.charat(0).touppercase() + this.slice(1).tolowercase(); };
using select2, wanted add class dropdown used dropdowncss instead of dropdowncssclass, changing fixes issue. real problem why jquery calls capitalize method on non string object if use string instead of object/function. weird.
Comments
Post a Comment