Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use this.name properly so widget in form behaves. #329

Merged
merged 1 commit into from
Feb 20, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions form/Rating.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,12 @@ define([
// Build the templateString. The number of stars is given by this.numStars,
// which is normally an attribute to the widget node.

var radioName = 'rating-' + Math.random().toString(36).substring(2);
this.name = this.name || 'rating-' + Math.random().toString(36).substring(2);

// The radio input used to display and select stars
var starTpl = '<label class="dojoxRatingStar dijitInline ${hidden}">' +
'<span class="dojoxRatingLabel">${value} stars</span>' +
'<input type="radio" name="' + radioName + '" value="${value}" dojoAttachPoint="focusNode" class="dojoxRatingInput">' +
'<input type="radio" name="' + this.name + '" value="${value}" dojoAttachPoint="focusNode" class="dojoxRatingInput">' +
'</label>';

// The hidden value node is attached as "focusNode" because tabIndex, id, etc. are getting mapped there.
Expand Down
14 changes: 11 additions & 3 deletions form/tests/test_Rating.html
Original file line number Diff line number Diff line change
Expand Up @@ -90,16 +90,24 @@ <h3>Inside a dojo form</h3>
dojo.require("dijit.form.FilteringSelect");
dojo.require("dijit.form.Button");
</script>
<form dojoType="dijit.form.Form">
<form jsId="rating2form" dojoType="dijit.form.Form">
<select dojoType="dijit.form.FilteringSelect">
<option>Does</option>
<option>this</option>
<option>work?</option>
</select>
<br /><br />
<div dojoType="dojox.form.Rating" numStars="5" value="1"></div>
<div jsId="rating2" dojoType="dojox.form.Rating" numStars="5" value="1" name="rating_widget_2"></div>
<br /><br />
<button dojoType="dijit.form.Button">Click me</button>
<button dojoType="dijit.form.Button">
<script type="dojo/event" data-dojo-event="onClick">
dojo.query('#rating2Value')[0].innerHTML = rating2.value;
dojo.query('#rating2FormValue')[0].innerHTML = JSON.stringify(rating2form.get('value'));
</script>
Click me</button>
<br /><br />
The value is: <b><span id="rating2Value">0</span></b>
The form value is: <b><span id="rating2FormValue">-empty-</span></b>
</form>
</body>
</html>