dojo

set icon for dijit.MenuItem

孤者浪人 提交于 2019-12-10 15:15:48
问题 We have a case where we only know the icon for a menu item at runtime. I know there is a iconClass parameter for a diji.MenuItem , but this is of little help unless we dynamically add CSS rules at runtime with dojox.html.insertCssRule - there must be a better way! Here is an example of what we are trying to do: pMenu = new dijit.Menu({ targetNodeIds: ["NEW_APP"], leftClickToOpen: true }); pMenu.popupDelay = 100; pMenu.addChild(new dijit.PopupMenuItem({ label: "clocks", iconSrc: "image/clocks

How to change cell formatting dynamically

你离开我真会死。 提交于 2019-12-10 12:04:51
问题 I hava implemented a datagrid using dojo which get updated every 5 seconds. I use following code to update the datagrid. jsonStore.fetch({ query: {id:'*'}, onComplete: function(items, result){ dojo.forEach(items, function(item){ jsonStore.setValue(item, "time" , data.update[0].netchange); ..... 'data' is the new data i need to set to the grid which is an json object as follows var data = {"update":[{...}]} what I need to do if the netchage is negative i need set cell color to red. if

how do dynamically create new option of drop down box using dojo

早过忘川 提交于 2019-12-10 11:17:55
问题 JavaScript code: var ref =dojo.byId("xyz"); var optn = document.createElement("OPTION"); optn.text="txt" optn.value="val" ref.options.add(optn); I want dojo equivalent of above code 回答1: i think that would be: var ref = dojobyId("xyz"); dojo.create("option", { value: "some", innerHTML: "label of option"}, ref); just read the documentation about the dom functions of dojo, it's simple enough. Good luck! 回答2: You are already using Dojo (dojo.byId). Dojo does not replace JavaScript (it augments

replace dojo.query with Sizzle?

两盒软妹~` 提交于 2019-12-10 11:05:48
问题 Dojo has got the slowest selectors compared to other JS frameworks. I was wondering if it was possible to use Sizzle within Dojo to make dojo.query use it behind the scenes? I think it is used in jQuery that way, so it should be possible in Dojo too. Couldn't find any info about how to do that. PS The test at the link seems to be being actively developed and changes daily, so make sure you select the latest version on that page. EDIT: it appeared that the numbers in the test were not correct,

How can I load non-AMD dependencies in the defined order with dojo?

情到浓时终转凉″ 提交于 2019-12-10 10:39:18
问题 I try to make a non-AMD library loadable with dojo, I've chosen a separate folder as a new (pseudo) AMD-package and placed the files of that library in that folder, together with the main.js file, which will get loaded by convention by the dojo loader when the package is requested. In this main.js file I simply put the names of my library files in the dependency list of the define() call. define([ "jquery", "./lib/jquery-ui/jquery-ui.min", "./the.actual.library.that.uses.the.others", ],

Submitting a form with a Dojo Rich Text Editor

人盡茶涼 提交于 2019-12-10 10:19:07
问题 Does anyone out there know how to submit a form that contains a Dojo Rich Text Editor? I've tried adding the "name" attribute to my element that is decorated with dojoType="dijit.Editor", however, I don't see any of the HTML on my receiving process. I've checked the documentation and I don't see any clear example (other than connecting the on submit event of the form in question with another function that sets the data of a hidden input with the "value" of the Rich Text Editor"). I would

Constrain position of Dojo FloatingPane

无人久伴 提交于 2019-12-10 03:49:26
问题 I have a dojox.layout.FloatingPane (as a custom dijit) which can be positioned anywhere within its enclosing div. My problem is that the user can potentially drag the FloatingPane completely outside of its container and be unable to retrieve it. Is there any easy way to force the FloatingPane to remain entirely visible at all times? Here's my code: dojo.provide("ne.trim.dijits.SearchDialog"); dojo.require("dijit._Widget"); dojo.require("dijit._Templated"); dojo.require("dojox.layout

Dojo require, connect to error when module failed loading

自作多情 提交于 2019-12-10 03:36:41
问题 When I try to load nonexistent module, it fail with 404 error (of course). I want to handle this error but don't know how to connect to "error" event. According to Dojo doc, I should be able to do that using its micro event api. This code does not work. var handle = require.on('error', function( error ) { alert('Finally error') }); require(['nonexistent/module'], function ( m ) { alert('Module was loaded correctly') }); Dojo version is 1.7.1, browser latest Chrome. 回答1: The documentation on

Get max and min of object values from JavaScript array

旧街凉风 提交于 2019-12-10 02:30:48
问题 What is the best way to get the maximum and minimum values from a JavaScript array of objects? Given: var a = [{x:1,y:0},{x:-1,y:10},{x:12,y:20},{x:61,y:10}]; var minX = Infinity, maxX = -Infinity; for( var x in a ){ if( minX > a[x].x ) minX = a[x].x; if( maxX < a[x].x ) maxX = a[x].x; } Seems a bit clumsy. Is there a more elegant way, perhaps using dojo? 回答1: Use this example var lowest = Number.POSITIVE_INFINITY; var highest = Number.NEGATIVE_INFINITY; var tmp; for (var i=myArray.length-1;

Difference between registry.byId and dom.byId in dojo? What is the advantage of using registry.byId?

笑着哭i 提交于 2019-12-10 01:51:52
问题 What is the difference between registry.byId and dom.byId in dojo? What is the advantage of using registry.byId ? In the code below I'm using dijit/registry and dojo/dom for both my textbox ( #myTextBox3 ) and my textbox node ( #textNode3 ). Only two of them are providing results. require(["dojo/parser", "dojo/dom", "dijit/registry", "dijit/form/TextBox", "dojo/domReady!"], function(parser, dom, registry) { parser.parse(); // Locate the JS object. var dibiWidget = registry.byId("myTextBox3");