Skip to main content

Bug Tracker

Side navigation

#6286 closed bug (worksforme)

Opened March 15, 2010 07:27AM UTC

Closed October 14, 2010 04:17PM UTC

Last modified July 15, 2013 11:19AM UTC

Unexpected call to method or property access.

Reported by: nata79 Owned by:
Priority: undecided Milestone: 1.4.3
Component: core Version: 1.4.2
Keywords: Unexpected call to method or property access Cc:
Blocked by: Blocking:
Description

By using "$(elId).text(myTextValue);" to set element text value, regardless ver1.3.2 or ver1.4.2, the exception "Unexpected call to method or property access" will throw by Internet Explorer 7/8.

The exception is throw at line "this.appendChild( elem );".

### CODE ###

text: function( text ) {

...

...

if ( typeof text !== "object" && text !== undefined ) {

return this.empty().append( (this[0] && this[0].ownerDocument || document).createTextNode( text ) );

}

...

},

append: function() {

return this.domManip(arguments, true, function( elem ) {

if ( this.nodeType === 1 ) {

this.appendChild( elem );

}

});

},

Attachments (0)
Change History (15)

Changed September 19, 2010 12:53PM UTC by jerone comment:1

I had this problem too, and I solved it with adding an HTML5 enabling script:

<!--[if lt IE 9]>
<script>
  var e = ("abbr,article,aside,audio,canvas,datalist,details," +
    "figure,footer,header,hgroup,mark,menu,meter,nav,output," +
    "progress,section,time,video").split(',');
  for (var i = 0; i < e.length; i++) {
    document.createElement(e[i]);
  }
</script>
<![endif]-->

Changed October 14, 2010 04:17PM UTC by addyosmani comment:2

priority: → undecided
resolution: → worksforme
status: newclosed

This is working fine for me. If you would like to submit additional test cases or further details to assist is in re-evaluating the original bug submitted we would be more than happy to take another look at it.

Changed January 07, 2011 07:11AM UTC by anonymous comment:3

This too does not work...!!! JQUERY 1.3.2 min.

The same old error.. of IE 7 & 8 ... "Unexpected call to method or property access."...

function getPeople(people) {

$("#people_list").text(""); //UL element ID

$("input#autoNames").text("");

$.each(people, function(i) {

$("#people_list").append("<li>" + this.Name + "</li>");

});

}

Problem statement: {this.appendChild(E)}

Changed January 08, 2011 05:09AM UTC by jitter comment:4

Your comment is rather unclear to me. If you could so kind to provide a reproducible minimal test case which shows this bug with the current jQuery version we will investigate this issue.


How to report bugs

Changed January 10, 2011 10:03AM UTC by anonymous comment:5

HTML:

<input type="text" id="autoNames" />

<label id="lblSelName">

</label>

<p>

<input type="button" id="addPerson" value="Add Person" />

<input type="button" id="deletCustomer" value="Delete Person" />

<input type="button" id="getPeople" value="Refresh List" />

<br />

<ul id="people_list">

</ul>

</p>

Script:

<script type="text/javascript">

$(this).ready(function() {

$.getJSON("/Home/PeopleGet", null, autoTextBox);

});

$(this).ready(function() {

$.getJSON("/Home/PeopleGet", null, getPeople);

});

function autoTextBox(people) {

var myCars = new Array();

$.each(people, function(i) {

myCars[i] = this.Name;

});

$("input#autoNames").autocomplete({

source: myCars

});

}

$(function() {

$("#getPeople").click(function() {

$.getJSON("/Home/PeopleGet", null, getPeople);

});

});

function getPeople(people) {

$("#people_list").text("");

$("input#autoNames").text("");

$.each(people, function(i) {

$("#people_list").append("<li>" + this.Name + "</li>");

});

$("input#autoNames").val('');

}

$("#addPerson").click(function() {

var name = $("input#autoNames")[0].value;

if (name == "") {

alert("You must provide a name");

return;

}

var person = { Name: name };

$.post("/Home/PeopleSave", person, null, "json");

$.getJSON("/Home/PeopleGet", null, getPeople);

alert("Customer is added to the database!");

$("input#autoNames").val('');

$("input#autoNames").focus();

});

$("#deletCustomer").click(function() {

var name = $("input#autoNames")[0].value;

if (name == "") {

alert("You must provide a name");

return;

}

var person = { Name: name };

$.post("/Home/PeopleDelete", person, null, "json");

$.getJSON("/Home/PeopleGet", null, getPeople);

alert("Customer successfully deleted from the database..!");

$("input#autoNames").val('');

$("input#autoNames").focus();

});

</script>

Changed July 16, 2011 10:55AM UTC by email@robertdewilde.nl comment:6

Bug still exists in 1.5.2;

// or var $menu = $input.after('<ul></ul>');

var $menu = $input.after('<ul />');

$menu.append("<li>item</li>");

IE 80.0.6001 on Win XP

Changed November 07, 2011 04:12PM UTC by david.m.mahon@gmail.com comment:7

I experienced the issue as well. The error was thrown when, somehow, in the context of append(), this referenced a SCRIPT tag and elem referenced a DIV.

I resolved the issue by rewriting append() to:

return this.domManip(arguments, true, function( elem ) {

if ( this.nodeType === 1 ) {

if (this.tagName.toUpperCase() === "SCRIPT") {

elem.appendChild( this );

}

else {

this.appendChild( elem );

}

}

});

Changed November 30, 2011 10:56AM UTC by anonymous comment:8

A simple jsfiddle, does not work with IE 8 no matter what version of jquery I use:

http://jsfiddle.net/4XZRT/

Changed November 30, 2011 11:17AM UTC by anonymous comment:9

Replying to [comment:8 anonymous]:

A simple jsfiddle, does not work with IE 8 no matter what version of jquery I use: http://jsfiddle.net/4XZRT/

Bad formed <a> tag, fix it and it works

Changed December 14, 2011 05:04PM UTC by anonymous comment:10

I have got the same error. I replaced .html with .replaceWith and it worked.

Changed December 16, 2011 05:26PM UTC by KendallB comment:11

Also getting the same error.

Changed April 15, 2013 02:21PM UTC by anonymous comment:12

i also had the same error in jquery-1.9.1

********************

the problem was i used

$('#elid').text('');

i replaced text with val and it worked for me :)

Changed May 06, 2013 04:49AM UTC by anonymous comment:13

Replying to [comment:1 jerone]:

I had this problem too, and I solved it with adding an HTML5 enabling script:
> <!--[if lt IE 9]>
> <script>
>   var e = ("abbr,article,aside,audio,canvas,datalist,details," +
>     "figure,footer,header,hgroup,mark,menu,meter,nav,output," +
>     "progress,section,time,video").split(',');
>   for (var i = 0; i < e.length; i++) {
>     document.createElement(e[i]);
>   }
> </script>
> <![endif]-->
> 

Changed May 09, 2013 06:37PM UTC by anonymous comment:14

This can happen in IE8 when using a class as a selector.

Imagine the following...

<p class="update_me">Some text</p>

<input class="update_me" type="text" name="something" value="123">

If you were to do the following in IE8 it would cause this error...

$('.update_me').text('456');

Other browsers will let you get away with it, but IE8 will complain as the input field isn't compatible with the .text() method.

Changed July 15, 2013 11:19AM UTC by matzipan comment:15

Happened to me, as well, while using .text("blabla") on an input.