dijit
dijit.tooltip with display column
Posted October 15th, 2008 by sunny_java
Hi,
i am new to dojo.
i am trying to use dijit.tooltip inside a display table column
i have to use it on a image source so that when i mouse over that image it will show me the dijit.tooltip with some message.
following is my code
this is working fine if is true for only one row
but when "" comes true for more than one rows
so i see the image in more than more rows of the column.
i see tooltip message only for the first row and not for other rows.
What i need is that where ever is my image dispayed in the column there on mouse over i should see the message.
can anybody help me with this.
thanks,
Sunny
get toolbar height and width
Posted September 3rd, 2008 by dmikester1I made a toolbar dijit and added some buttons to it. Then I would like to get the height and width of the toolbar. How would I do this?
Thanks
Mike
dialog dijit holding variables
Posted August 26th, 2008 by dmikester1I am writing an app where i select a checkbox and then click a button and it pops up a dialog digit where I can input some variables. I put in some variables, and hit OK. Then it does some work. Now I select a different checkbox and click the same button to pop up the dialog and the variables are still in there. Why does this happen?
Thanks
Mike
Spicing up old date input forms using Dojo's DateTextBox widget
Posted November 2nd, 2007 by achillean in
I've recently been working a lot w/ Django and have used some of its facilities to automatically generate forms. While that's pretty nifty, I wanted the date fields to be assisted by javascript, more specifically Dojo. I think it's fair to say that most new websites need to have a dropdown date calendar when letting the user select a date. Fortunately, this turns out to be very simple using Dojo.
The general gist of the way I implemented this was to:
For obvious reasons I'm going to keep the form short and simple, but just wanted to make sure we're all on the same page (no pun intended). Anyways, here's the javascript code that I use (Warning: assumes that you've already loaded the dojo.js file, please refer to the xhrGet/ xhrPost story for details on how to do that).
The first function in the code is string_to_date. I couldn't find a good Dojo function that simply takes a string (in the 'YYYY-MM-DD' format) and converts it to a Date object, so I hacked that together briefly (got parts of it from old Dojo code). You should do more error-checking in a production environment, but it'll do for this example.
Afterwards, I define the init_form function, which finds the form element, takes its value (if it exists) and converts it to a Date object, and then finally feeds all of the info the the DateTextBox constructor. It's important that you give the constructor the name parameter to make sure your current form-parsing code (in PHP, Python, whatever) still works, since Dojo by default doesn't assign a name to the DateTextBox input field.
And lastly, we tell dojo to call the init_form function once the page has been loaded. And that's it! It's really not a lot of code or complicated logic, so I hope you'll try and spice up ye olde web forms you've got lying around using Dojo.
The general gist of the way I implemented this was to:
- Let Django create the HTML form.
- Create a function that gets called onLoad and turns specific fields into DateTextBoxes by programmatically creating them.
<form action='.' method='POST'>
Birth Date: <input type='input' name='birth_date' />
</form>
Birth Date: <input type='input' name='birth_date' />
</form>
For obvious reasons I'm going to keep the form short and simple, but just wanted to make sure we're all on the same page (no pun intended). Anyways, here's the javascript code that I use (Warning: assumes that you've already loaded the dojo.js file, please refer to the xhrGet/ xhrPost story for details on how to do that).
function string_to_date (args) {
args = dojo.string.trim(args);
arr = args.split('-');
return new Date (parseInt(arr[0]), parseInt(arr[1], 10) - 1, parseInt(arr[2].substr(0,2), 10));
}
// Add the DateTextBox widget
function init_form () {
dojo.require('dijit.form.DateTextBox');
dojo.require('dojo.date');
dojo.require('dojo.string');
// Birth Day
var div = document.getElementsByName('birth_date')[0];
var val = ''
if (dojo.string.trim(div.value) != '') {
val = string_to_date (div.value);
}
var w = new dijit.form.DateTextBox ({
name: div.name,
value: val
}, div);
}
dojo.addOnLoad (init_form);
args = dojo.string.trim(args);
arr = args.split('-');
return new Date (parseInt(arr[0]), parseInt(arr[1], 10) - 1, parseInt(arr[2].substr(0,2), 10));
}
// Add the DateTextBox widget
function init_form () {
dojo.require('dijit.form.DateTextBox');
dojo.require('dojo.date');
dojo.require('dojo.string');
// Birth Day
var div = document.getElementsByName('birth_date')[0];
var val = ''
if (dojo.string.trim(div.value) != '') {
val = string_to_date (div.value);
}
var w = new dijit.form.DateTextBox ({
name: div.name,
value: val
}, div);
}
dojo.addOnLoad (init_form);
The first function in the code is string_to_date. I couldn't find a good Dojo function that simply takes a string (in the 'YYYY-MM-DD' format) and converts it to a Date object, so I hacked that together briefly (got parts of it from old Dojo code). You should do more error-checking in a production environment, but it'll do for this example.
Afterwards, I define the init_form function, which finds the form element, takes its value (if it exists) and converts it to a Date object, and then finally feeds all of the info the the DateTextBox constructor. It's important that you give the constructor the name parameter to make sure your current form-parsing code (in PHP, Python, whatever) still works, since Dojo by default doesn't assign a name to the DateTextBox input field.
And lastly, we tell dojo to call the init_form function once the page has been loaded. And that's it! It's really not a lot of code or complicated logic, so I hope you'll try and spice up ye olde web forms you've got lying around using Dojo.
Dojo Forum