EzDevInfo.com

dojo interview questions

Top dojo frequently asked interview questions

Can I get the name of the currently running function in JavaScript?

Is it possible to do this:

myfile.js:
function foo() {
    alert(<my-function-name>);
    // pops-up "foo"
    // or even better: "myfile.js : foo"
}

I've got the Dojo and jQuery frameworks in my stack, so if either of those make it easier, they're available.


Source: (StackOverflow)

JavaScript simulate right click through code

I am writing some UI tests using Selenium and i have a JavaScript Tree control, using the Dojo toolkit.

I have implemented a context menu for each node of the tree using the examples that Dojo provide, but I need the Selenium test to "invoke" the right click on the tree node, but I cannot get this to work. The tests simply do not simulate the right-click event through JavaScript, and the context menu does not show up.

Has anyone had any experience in invoking the right click on a context menu using Dojo and Selenium? Or have any ideas as to how to do it?

Thanks for any help that you can give.

Mark


Source: (StackOverflow)

Advertisements

How to export JavaScript array info to csv (on client side)?

I know there are lot of questions of this nature but I need to do this using JavaScript. I am using Dojo 1.8 and have all the attribute info in array, which looks like this:

[["name1", "city_name1", ...]["name2", "city_name2", ...]]

Any idea how I can export this to csv on the client side?


Source: (StackOverflow)

Warning : The page index.html ran insecure content

I deployed my application on google appe engine. My web site use Dojo with the template claro. When I run "google chrome inspection", I see a lot of warning when I navigate throught my site. Here is the type of warnings :

The page index.html ran insecure content from http://ajax.googleapis.com/ajax/libs/dojo/1.5/dijit/themes/claro/claro.css.
The page index.html ran insecure content from http://ajax.googleapis.com/ajax/libs/dojo/1.5/dojo/dojo.xd.js.

Do I need to configurate something in the appengine-web.xml or web.xml?


Source: (StackOverflow)

How to check if an object has a function? (DoJo)

var testObj = this.getView();

How can I check with DoJo (or just native JS) if testObj has callableFunction before I actually try to call callableFunction() and fail if it isn't there? I would prefer a native-DoJo solution as I need this to work on all browsers.


Source: (StackOverflow)

Comparing backbone.js and Dojo

I'm looking at settling on my JS toolbox. For some product reasons dojo will be in there. Now I wonder if adding backbone.js makes sense. Do Dojo (which does a few other things - I'm aware of that) and backbone.js overlap or complement? What would be the conceptual differences in overlapping parts? Are there examples that use both together? (I know it is a rather broad question and might show my 2nd level of ignorance)


Source: (StackOverflow)

Remove all the children DOM elements in div

I have the following dojo codes to create a surface graphics element under a div:

....
<script type=text/javascript>
....
function drawRec(){
var node = dojo.byId("surface");
//   remove all the children graphics
var surface = dojox.gfx.createSurface(node, 600, 600);

surface.createLine({
  x1 : 0,
  y1 : 0,
  x2 : 600,
  y2 : 600
  }).setStroke("black");
}
....
</script>
....
<body>
<div id="surface"></div>
....

drawRec() will draw a rectangle graphics first time. If I call this function again in an anchor href like this:

<a rel='nofollow' href="javascript:drawRec();">...</a>

it will draw another graphics again. What I need to clean all the graphics under the div and then create again. How can I add some dojo codes to do that?


Source: (StackOverflow)

dojox.gfx bounding box for Text and Group nodes

The documentation for getBoundingBox() in dojo says:

Returns a bounding box of a shape. A text shape is a point-based object, so it doesn't define a bounding box.

I don't get it. Any sane implementation of vector graphics for the web includes bounding box for text objects (raphaelJS and jQuery SVG that is)! Here, what does "a point based object" mean?

I found no reference for a bounding box for Group object, but when using the latest Dojo version, getBoundingbox returns null for Groups as well

I can easily do bounding box for rectangle myself, but the only really problematic shapes I need bounding box for are the Group and the Text.

I ended hotpatching dojo like:

dojox.gfx.Text.prototype.getBoundingBox = function() { return this.rawNode.getBBox();});
dojox.gfx.Group.prototype.getBoundingBox = function() { return this.rawNode.getBBox();});

Which will of course work only for the SVG output front end.

But I wonder, am I missing something? Is there a better way to do that?


Source: (StackOverflow)

REST vs. RPC in PHP [closed]

I'm building my own ajax website and I'm contemplating between REST and RPC.
If my server supported Servlets I'd just install persevere and end the problem but my Server doesn't support Servlets.
RPC is simpler to code (imo) and can be written in PHP easily.
All I need is a database query executer.
I'm using the Dojo Toolkit and JSON.

Why should I choose REST over RPC or RPC over REST?


Source: (StackOverflow)

What is an easing function?

What is meant by easing function in the context of animation. It seems that dojo, jquery, silverlight, flex and other UI systems have the notion of easing function. I could not locate a good explanation of easing functions? Can anyone explain the concept of easing functions, or point a good explanation of them, I am interested in the concept not in the specific details of a framework?

Is easing strictly used for location or is it general and can be applied to any property of an object?


Source: (StackOverflow)

What happened to Dojo in 2008?

Many of you have seen this graph of Google Trends of popular AJAX frameworks (Dojo, jQuery, YUI).

The graph seems to make it clear that interest in Dojo collapsed in the second quarter of 2008, falling by 80%; jQuery picked up the slack and ultimately grew to more than triple the size of Dojo.

Why? What happened in Q2 2008 that demolished interest in Dojo?

(Note that I'm not really interested in a comparison of Dojo vs. jQuery; even if you can explain why one is better than the other, it's hard to see why that suddenly became clear to the world in April 2008.)


Source: (StackOverflow)

how to catch ALL javascript errors with window.onerror? (including dojo)

this question is a follow-up to javascript: how to display script errors in a popup alert? where it was explained how to catch regular javascript errors using:

<script type="text/javascript">
    window.onerror = function(msg, url, linenumber) {
        alert('Error message: '+msg+'\nURL: '+url+'\nLine Number: '+linenumber);
        return true;
    }
</script>

I tried it and found out that dojo erros like this one:

TypeError: this.canvas is undefined         dojo.js (Row 446)

were not reported using this method, which leads me to my question:

How can I report all javascript errors using window.onerror (especially dojo errors)?


Source: (StackOverflow)

How can live search / search suggestions be implemented using Dojo?

I want to implement a 'live search' or 'search suggestions' feature in a web application that uses the Dojo Framework. It would be similar to the way Google and Bing searches display matches as you type: when you type in the search box, a list of potential matches appears below. Searches would be performed server side, with the results sent back to the browser using AJAX.

Does anyone know of a good way to implement this using Dojo?

Here are some potential options:

  • The built-in widget dijit.form.ComboBox
    This has very similar functionality, but I've only seen it used with limited data sets. The examples always use small lists (such as the 50 states in USA) and preload the entire data set for client-side filtering. However I presume I could hook it up to a dojox.data.JsonQueryRestStore for server-side search — can anyone confirm whether that works?

  • QueryBox http://marumushi.com/code/querybox/
    This implementation mainly does the job, but it has some minor bugs and doesn't look like it's being maintained. I'd have to do some bugfixes on the code before using it.

  • Medryx http://blog.medryx.org/2008/09/10/dijitsearch-part-2/
    This also looks like it does the job, but it is described as 'alpha-level' code and the link to the code seems to be broken...

I could probably make one of the above work, but I'd like to know if there are any better alternatives out there.


Source: (StackOverflow)

Using dgrid in form collections in a Zend Framework 2 application

For our new project, we have started using Zend Framework 2 and Dojo 1.8. ZF2 has a completely rewritten form module, which now features the new CollectionElement for one-to-many relationships. Regarding UI I find, that dgrid fits best for such relationships (using the editor column plugin), so I started extending FormCollection, FormRow and FormElement view helpers, so they can render the desired dgrid. Everything was fine until I realized, that I cannot set per-row input names for the dgrid widgets.

I started with the ZF2 documentation rearding form collections. One can see, that collection input elements have array-like names like

order[products][0][name]
order[products][0][price]
order[products][1][name]
order[products][1][price]

On the other hand, dgrid's configuration is column based, so I can have a column definition like

editor({
    field: "_dojo_textbox_505ee3a390d705_26717315", 
    label: "Name",
    editorArgs: {
        name: "order[products][{index}][name]",
    }
}, TextBox)

This column definition will define set the same widget name for all rows, which does not work with the ZF2 collection data format requirement.

What I also tried is naming the column like this:

order[products][]

which works, but does not allow the desired format

order[products][][name]

Maybe there is a way to post the data like this:

order[products][name][]

and have it converted afterwards, but the solution doesn't looks right. Beside this I am trying to produce reusable code and want to avoid per-form data modifications.

Since I am trying very hard to avoid onSubmit/onClick event handling for data conversion, there are 2 possible solutions: 1. Make dgrid able to set per-row widget names 2. Make ZF2 form understand some other-than-standard POST format for collections

Unfortunately I ran out of ideas, how either of those solutions can be done, so I will be most thankful, if you can give me a hand with this!

Since this is somewhat related with my current question, I will place it here as a side question: What other than this UI solution do you use for your one-to-many form interfaces with dojo?


Source: (StackOverflow)

jQuery / Dojo - How do I use jQuery with Dojo toolkit

How do I use jQuery with Dojo toolkit? I've heard of both libraries being used simultaneously, jQuery for DOM-related and Dojo for UI (dijit), but I can't find any tutorials or examples of this. Will I run into any conflicts or issues if I load both libraries?


Source: (StackOverflow)