aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--build/test/data/test3.html3
-rw-r--r--src/ajax/ajax.js6
-rw-r--r--src/ajax/ajaxTest.js9
3 files changed, 16 insertions, 2 deletions
diff --git a/build/test/data/test3.html b/build/test/data/test3.html
new file mode 100644
index 000000000..909d41745
--- /dev/null
+++ b/build/test/data/test3.html
@@ -0,0 +1,3 @@
+<div class="user">This is a user</div>
+<div class="user">This is a user</div>
+<div class="teacher">This is a teacher</div>
diff --git a/src/ajax/ajax.js b/src/ajax/ajax.js
index 795cd8a9e..ccf4f14a9 100644
--- a/src/ajax/ajax.js
+++ b/src/ajax/ajax.js
@@ -49,8 +49,10 @@ jQuery.fn.extend({
return this.bind("load", url);
var off = url.indexOf(" ");
- var selector = url.slice(off, url.length);
- url = url.slice(0, off);
+ if ( off >= 0 ) {
+ var selector = url.slice(off, url.length);
+ url = url.slice(0, off);
+ }
callback = callback || function(){};
diff --git a/src/ajax/ajaxTest.js b/src/ajax/ajaxTest.js
index 4d4bc0791..0fd4888ac 100644
--- a/src/ajax/ajaxTest.js
+++ b/src/ajax/ajaxTest.js
@@ -94,6 +94,15 @@ test("load(String)", function() {
$('#first').load("data/name.html", start);
});
+test("load('url selector')", function() {
+ expect(1);
+ stop(true); // check if load can be called with only url
+ $('#first').load("data/test3.html div.user", function(){
+ equals( $(this).children("div").length, 2, "Verify that specific elements were injected" );
+ start();
+ });
+});
+
test("load(String, Function) - simple: inject text into DOM", function() {
expect(2);
stop();