Reputation: 7388
I'm generating a link in dojo as a string. How would I use dojo to actually go to that link?
For instance:
require(["dojo/linkfollowinglibrary"], function(linklibrary){
var string = "http://www.example.com/Search/Here-is-the-searchstring/"
linklibrary.gotolink(string);
});
What is the actual linkfollowinglibrary and what is the call in there that represents gotolink? I'm having difficulty searching it for some reason.
Upvotes: 0
Views: 59
Reputation: 7388
My dojo based solution:
require(["dojo/on", "dojo/dom-construct", "dojo/domReady!"], function (on, domConstruct) {
var searchString = "The contents of the search box";
var searchUrl = "/Search/" + searchString;
var searchlink = domConstruct.toDom("<a href="+searchUrl+"/>");
on.emit(searchlink, "click", { bubbles: true, cancelable: true });
});
Upvotes: 0
Reputation: 10559
There's nothing special in Dojo to do this, because setting location.href
already accomplishes this in all browsers:
location.href = "http://www.example.com/Search/Here-is-the-searchstring/";
Dojo doesn't ordinarily invent APIs unless they add convenience, mitigate cross-browser incompatibilities, or both. In this case, It's Just JavaScript.
Upvotes: 1