getting an error "no method 'apply'"

Dec 11, 2013 at 7:56 AM
Edited Dec 11, 2013 at 8:06 AM
Hi,

I am useing rateIt with my backbone project.
When i click to rate i use to get an error

"Uncaught TypeError: Object rateAnswer has no method 'apply' "

rateAnswer is my buit in function which i called as
$('#products  .rateit').bind('rated reset', 'rateAnswer');

rateAnswer : function(){

                    var ri = $(this),
                    appCollectObj = new appCollection();

                    var value = ri.rateit('value');
                    var questionId = ri.data('productid');
             
                    //maybe we want to disable voting?
                    ri.rateit('readonly', true);

                    appCollectObj.fetch({
                        data: $.param({questionId : questionId, value : value}),
                        success: function(model, response) {
                                $('#response').append('<li>' + data + '</li>');
                                },
                        error: function() {
                                $('#response').append('<li style="color:red">' + msg + '</li>');
                                }
                    });
        }

    });
And HTML
<div id="products">
            <ul>
              <li>
               RateIt: <div data-productid="<%= elem.id %>" class="rateit"></div>
              </li>
            </ul>
            <ul id="response"></ul>
          </div>
Please help
Coordinator
Dec 11, 2013 at 9:56 AM
Hi,

It's a simple javascript error:

change:
$('#products .rateit').bind('rated reset', 'rateAnswer');

into:

$('#products .rateit').bind('rated reset', rateAnswer);
Dec 11, 2013 at 10:16 AM
thanks my bad .. passed string instead of function