0x800a01b6 - JavaScript runtime error: Object doesn't support property or method 'SumoSelect'

0

I'm getting the above error message when trying to call the SumoSelect function against a select option element on an aspx page.

I have the following references in my web page:

<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.js" type="text/javascript"></script>
<script src="jquery.sumoselect.js"  type="text/javascript"></script>
<link href="sumoselect.css" rel="stylesheet" />

With the files taken from: https://github.com/HemantNegi/jquery.sumoselect/zipball/master

At present I have only included the following in my project from the download:

  1. jquery.sumoselect.js

  2. sumoselect.css

My jQuery is correctly locating one of the element with:

<script type="text/javascript">
$(document).ready(function () {

  var elements = document.getElementsByTagName("*");

  for (i = 0; i < elements.length; i++) {
    element = elements[i];
    name = element.id;

    if (name.match(/FieldId_3/)) {
      $(element).SumoSelect();
    }
  }
});
</script>

However, when it reaches $(element).SumoSelect(); it produces the error "0x800a01b6 - JavaScript runtime error: Object doesn't support property or method 'SumoSelect'"

I'm very new to jQuery/Javascript, but have tried multiple permutations of trying to call this function and pass the object, however none have worked.

Any ideas to help me get it working?

I'll be grateful for any assistance.

javascript
jquery
html
sumoselect.js
asked on Stack Overflow Oct 27, 2015 by Malieki • edited Jul 31, 2018 by Nimeshka Srimal

3 Answers

0

first of all, you are using jQuery, why bother using Vanilla JavaScript to get DOM Elements, and iterate over all collection, only to get one element by its id? (id property should be unique in the document)

You can refactor your code and initialize your plugin only on the elements that meet the selector criteria:

$(document).ready(function () {
  $('#FieldId_3').SumoSelect();
});

If no elements meet the criteria, the plugin not will be initialized (safely), because jQuery return an empty like-array object.

And obviously, the element with id FieldId_3 must be a select element, as mentioned here: https://hemantnegi.github.io/jquery.sumoselect/

answered on Stack Overflow Oct 27, 2015 by jherax
0

The method you are using to run SumoSelect is, as the others have said, somewhat overkill, to put it mildly.

However, I have tested your code and it does work, assuming that the jquery.sumoselect.js file is in the same directory as the HTML file in question.

I would suggest, then, that your problem is that the SumoSelect jQuery plugin is not being found.

Once that error is fixed, however, you should run SumoSelect in the manner suggested by Nick R.

answered on Stack Overflow Oct 27, 2015 by (unknown user)
-1

(I work with Malieki and have picked this up, for completeness...) After a couple of hours trial and erroring, I found that when I comment out the code below, the sumoselect part starts working ok. We where experimenting with Saplin.Controls DropDownCheckBoxes first and then found sumoselect but we left a control in the same aspx (for Saplin).

    <asp:DropDownCheckBoxes ID="TypeCB" runat="server" OnSelectedIndexChanged="TypeCB_SelectedItemsChanged" AutoPostBack="True" Font-Size="7pt" font-family="Verdana" CssClass="txt_box"
    AddJQueryReference="True" meta:resourcekey="checkBoxes2Resource1" UseButtons="True" UseSelectAllNode="False">  
    <Style2 SelectBoxWidth="160" DropDownBoxBoxHeight="230" DropDownBoxBoxWidth="200" />
    <Texts OkButton="Ok" CancelButton="Cancel" SelectAllNode="ALL" SelectBoxCaption="Type" />
    </asp:DropDownCheckBoxes>

When this control is removed the sumo jquery stuff all starts working ok. I can only assume a conflict between them. Thanks for the help though guys, we're both new to this.

answered on Stack Overflow Nov 3, 2015 by mestucky

User contributions licensed under CC BY-SA 3.0