jQuery's load method allows loading page fragments by passing in a selector as part of the URL.
It would be very useful if jQuery UI tabs could do the same in Ajax mode - for pretty much the same reason the load method supports this.
At first I figured this was a common issue and I was just missing something, but some investigation of the source confirms that this is currently not supported.
Thoughts, ideas?
Update:
For the moment, I've worked around this with an ugly hack:
$(".ui-tabs").tabs({
load: function(event, ui) {
var content = $("#main", ui.panel).html();
$(ui.panel).html(content);
}
});
However, that leads to the original content flashing briefly before the contents are reset (also because the remote page's style sheets and scripts are being loaded) - unfortunately, there doesn't seem to be a hook that would allow us to suppress this (by hiding the panel contents before the original is inserted).
Not being content with browser-based testing - it disrupts my workflow and complicates automated testing - I've written a set of small scripts to run QUnit tests from the command line (using Spidermonkey or Node.js - or potentially any other JavaScript engine): http://github.com/FND/kopfloss Some background is explained here: http://fnd.lewcid.org/blog/archive/157
I figured this was worth sharing here, and would appreciate feedback - constructive criticism included!
While jQuery's tendency to (deliberately) swallow exceptions can be useful, it can lead to some annoyances. In particular, this often makes debugging unnecessarily painful (especially in callbacks).
In order to mitigate this issue, it might be useful for jQuery to fire a custom event when an exception is being trapped. That would allow developers to decide how they want to handle exceptions without compromising current behavior. Does this seem reasonable?
(It appears this issue has not been brought up here before. As that seems unlikely, I'd appreciate pointers to any previous discussions.)
This will result in a GET to /home after the POST, before any callbacks are processed. How can I suppress this automatic 303 handling? (using jQuery v1.4.2 on Firefox)
Thanks!
Update: It appears this is not directly related to jQuery, but rather the underlying XHR. There might still be a way to control this though... !?
It's fairly primitive at the moment, and I'm aware of the (more exciting) alternatives* - but perhaps someone else can make use of this for some airborne hacking.
As far as I can tell, the raw XML API dump (http://api.jquery.com/api/) is not being served properly. That URL returns index.html with content type not set to {text,application}/xml. Also, the document is missing an XML declaration at the top (not sure whether that's a problem though).
This means I can't retrieve and parse it via $.ajax - the following raises a parsererror:
jQuery.ajax({
type: "GET",
url: "http://api.jquery.com/api/",
dataType: "xml",
success: function(data, status, xhr) {
console.log("success", arguments);
},
error: function(xhr, error, exc) {
console.log("error", arguments);
}
});
(running from Firebug on api.jquery.com to avoid same-origin restrictions, or from a file:// URI)
If my assumptions above are correct, I'd appreciate if the server config could be adjusted.
Hello, While getting to know QUnit, I noticed that there is currently no way to test for the occurrence of exceptions. Looking at the QUnit source, it appears this might be an easy thing to add: http://gist.github.com/76340 That way one could write tests like so: var expression, expected; var L = ["foo", "bar", "baz"]; // should pass expression = function() { return foo.bar; }; expected = "TypeError"; throwsEx(expression, expected, "invalid property access raises TypeError exception"); // should fail expression = function() { var foo = {}; return foo.bar; }; expected = "NoneError"; throwsEx(expression, expected, "property access raises NoneError exception"); Note that I'm using closures to wrap around the expression which is actually being tested. Does this seem sensible? I'd be happy to submit a patch on request. -- Fred