I'm surprised it has to be done in jquery.
But if it works, I'm all for it.
Thanks again.
On Dec 27, 9:16 am, Chris Lawlor <lawlor.ch...@gmail.com> wrote:
> Michael,
>
> In one of my projects, I did something like this:
>
> <form id='stars' action='/some/url' method='post'>
> {% for field in rating_form %}
> <li>{{ field}}</li>
> {% endfor %}
> <li><input type='submit' value='Rate'/></li>
> </form>
>
> $('#stars').children().not(":radio").hide()
> $('#stars').stars({
> cancelShow: false,
> callback: function(ui, type, value){
> ajaxVote(value);
> }
> });
>
> function ajaxVote(value) {
> $.ajax({ url: '{% url plugin-rate object.slug %}',
> type: 'POST',
> data: { rating: value },
> dataType: 'json',
> success: function(data){
> var avg_rating = data['avg_rating']
> var votes = data['votes']
> $('#rating_display').html(avg_rating +" out of 5 (Rated " +
> votes + " times)")
> },
> });
> }
>
> The key to hiding the other form elements (like the labels) is the $
> ('#stars').children().not(":radio").hide() call, which basically hides
> everything but the actual stars. If the use doesn't have JS enabled,
> they should still see the radio buttons with the associated labels.
>
> Hope that helps,
>
> Chris
>
> On Dec 27, 6:48 am, Michael Thamm <webmas...@morningcat.com> wrote:
>
> > One thought, and this maybe the whole issue, is that the radio button
> > is using labels for the text and not titles.
> > I would expect the output to be something like this:
> > <input type="radio" name="newrate" value="1" title="Very poor" />
> > but instead the output is like this:
> > <label for "newrate">
> > <input type="radio" name="newrate" value="1" />
> > 1
> > </label>
>
> > Is this something that anyone else has had to deal with?
>
> > Thanks
> > Michael
>
> > On Dec 27, 6:39 am, Michael Thamm <webmas...@morningcat.com> wrote:
>
> > > Hi,
> > > I am using the jQuery stars on a radio field as a custom renderer. The
> > > stars come up nicely but the
> > > choice text still displays to the side of the stars.
> > > How can I not show the choice text but still populate the field with
> > > the choice result?
> > > I am displaying the field in the template like this:
> > > {{ userForm.fitStars }}
>
> > > BTW - I am not talking about the label text. For example,
> > > How was your meal?
>
> > > But rather the radio button choices.
>
> > > The radio button text I want to not display.
>
> > > Thanks
> > > Michael
--
You received this message because you are subscribed to the Google Groups "Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to django-users+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
No comments:
Post a Comment