0

I've got a interesting situation. I've got a controler with the call

            Todo.Models.PersonAddress.findAll({
                personId:personId
            }, this.callback('list'));

In the model we've got:

findAll: function( params, success, error ){
    $.ajax({
        url: '/person/get-address-json',
        type: 'post',
        dataType: 'json',
        data: params,
        success: this.callback(['wrapMany',success]),
        error: error
    });
},

Theses work just perfect. However I'd like to change my model to bring a JSON string that I already have in my current code.. It'd look like:

findAll: function( params, success, error ){

    var source = jQuery.parseJSON($('#address-personData').val());
    var person_addresses = this.wrapMany(source);
    this.callback(person_addresses, success);
}

But the callback() doesn't work at all and doesn't give any error ou notice. Could any one help me with that issue? All I want is just bring the same information as the one with $.ajax.

ThiefMaster
  • 310,957
  • 84
  • 592
  • 636
medina
  • 8,051
  • 4
  • 25
  • 24
  • I found the answer: findAll: function( params, success, error ){ var source = jQuery.parseJSON($('#address-personData').val()); var person_addresses = this.wrapMany(source); if(success){ success(person_addresses); } }, – medina Jun 08 '12 at 16:57
  • 3
    Write your comment as an answer and accept it to indicate your question as solved – Thor Jun 09 '12 at 07:39

1 Answers1

0

You can just call the success method here. Try success();

Stephan
  • 41,764
  • 65
  • 238
  • 329
Panna Ahmed
  • 11
  • 1
  • 4