Should I be able to execute a passed block from within the success block of an ajax call? ------ fetchOnSuccessDo: aBlock jQuery
ajax: uri options: #{ 'type' -> 'GET'. 'dataType' -> 'jsonp'. 'success' -> [ :aJSONObject | self initializeFrom: aJSONObject. aBlock value ].
'error' -> [window alert: 'error'] } ----- javascript console says "Cannot call method 'apply' of undefined", trying to call _value there
|
Hmm, that's odd. There's no reason why it shouldn't work. And the JS
equivalent works fine: function foo(fn) { jQuery.ajax({ url: '/', success: function() {fn()} }); } foo(function() {alert('it works!')}) Can you add a minimal example showing the issue on the bug tracker? Cheers, Nico On Wed, 2012-01-04 at 09:12 -0500, Joel Turnbull wrote: > > > Should I be able to execute a passed block from within the success > block of an ajax call? > > > ------ > > > fetchOnSuccessDo: aBlock > > > jQuery > ajax: uri > options: #{ > 'type' -> 'GET'. > 'dataType' -> 'jsonp'. > 'success' -> [ :aJSONObject | self initializeFrom: > aJSONObject. aBlock value ]. > 'error' -> [window alert: 'error'] > } > > > ----- > > > javascript console says "Cannot call method 'apply' of undefined", > trying to call _value there |
Hi guys,
I know we still have some issues left for 0.9.1, but I think it's really time for a release. So I propose moving the remaining issues to 0.9.2 and releasing :) Cheers, Nico |
On Thu, Jan 5, 2012 at 9:23 PM, Nicolas Petton <[hidden email]> wrote: Hi guys, I agree. Laurent
|
In reply to this post by Nicolas Petton
I get that error, when I try to access a not-yet stetted ivar (the ivar being undefined then).
On Thu, Jan 5, 2012 at 9:16 PM, Nicolas Petton <[hidden email]> wrote: Hmm, that's odd. There's no reason why it shouldn't work. And the JS |
Ok digging in a little bit more but still confused. Before I submit a simple case to the issue tracker, let me extrapolate again and make sure I'm not trying to do something that is just not going to work.
There seems to be no problem with evaluating that block from within the ajax success, except when that block is send from a TestCase and attempting to do an assert? ------
testFetch | library | library := FetchedCollection on: Array new
self assert: library isEmpty. library fetchOnSuccessDo: [ self assert: library notEmpty ]. ------ Should that work? If so, I'll work up that simple case for the issue tracker.
If I just plug something simple into that block instead the block stays defined and gets evaluated, e.g. ------ library fetchOnSuccessDo: [ window alert: 'hello there' ].
------ Thanks. On Fri, Jan 6, 2012 at 5:59 AM, Amber Milan Eskridge <[hidden email]> wrote: I get that error, when I try to access a not-yet stetted ivar (the ivar being undefined then). |
Hi,
I don't see a reason why it shouldn't work. Cheers, Nico On Fri, 2012-01-06 at 15:12 -0500, Joel Turnbull wrote: > > > Ok digging in a little bit more but still confused. Before I submit a > simple case to the issue tracker, let me extrapolate again and make > sure I'm not trying to do something that is just not going to work. > > > There seems to be no problem with evaluating that block from within > the ajax success, except when that block is send from a TestCase and > attempting to do an assert? > > > ------ > > > testFetch > | library | > > library := FetchedCollection > on: Array new > at: 'http://localhost/couchdb/recipes/_all_docs'. > > > self assert: library isEmpty. > library fetchOnSuccessDo: [ self assert: library notEmpty ]. > > > ------ > > > Should that work? If so, I'll work up that simple case for the issue > tracker. > > > If I just plug something simple into that block instead the block > stays defined and gets evaluated, e.g. > > > ------ > > > library fetchOnSuccessDo: [ window alert: 'hello there' ]. > > > ------ > > > Thanks. > > > > > > > On Fri, Jan 6, 2012 at 5:59 AM, Amber Milan Eskridge > <[hidden email]> wrote: > I get that error, when I try to access a not-yet stetted ivar > (the ivar being undefined then). > > > On Thu, Jan 5, 2012 at 9:16 PM, Nicolas Petton > <[hidden email]> wrote: > Hmm, that's odd. There's no reason why it shouldn't > work. And the JS > equivalent works fine: > > function foo(fn) { > jQuery.ajax({ > url: '/', > success: function() {fn()} > }); > } > foo(function() {alert('it works!')}) > > Can you add a minimal example showing the issue on the > bug tracker? > > Cheers, > Nico > > On Wed, 2012-01-04 at 09:12 -0500, Joel Turnbull > wrote: > > > > > > Should I be able to execute a passed block from > within the success > > block of an ajax call? > > > > > > ------ > > > > > > fetchOnSuccessDo: aBlock > > > > > > jQuery > > ajax: uri > > options: #{ > > 'type' -> 'GET'. > > 'dataType' -> 'jsonp'. > > 'success' -> [ :aJSONObject | self > initializeFrom: > > aJSONObject. aBlock value ]. > > 'error' -> [window alert: 'error'] > > } > > > > > > ----- > > > > > > javascript console says "Cannot call method 'apply' > of undefined", > > trying to call _value there > > > > > > |
Ok, I recreated the class and got it working, never tracked down the exact problem, but I'm using doesNotUnderstand: and I suspect the undefined thing attempting to call _value may not have been the block at all. Seems like programmer error and not a bug. Thanks guys.
On Sat, Jan 7, 2012 at 7:24 AM, Nicolas Petton <[hidden email]> wrote: Hi, |
Glad it works :)
Cheers, Nico On Sun, 2012-01-08 at 14:25 -0500, Joel Turnbull wrote: > > > Ok, I recreated the class and got it working, never tracked down the > exact problem, but I'm using doesNotUnderstand: and I suspect the > undefined thing attempting to call _value may not have been the block > at all. Seems like programmer error and not a bug. Thanks guys. > > > > > > On Sat, Jan 7, 2012 at 7:24 AM, Nicolas Petton > <[hidden email]> wrote: > Hi, > > I don't see a reason why it shouldn't work. > > Cheers, > Nico > > On Fri, 2012-01-06 at 15:12 -0500, Joel Turnbull wrote: > > > > > > Ok digging in a little bit more but still confused. Before I > submit a > > simple case to the issue tracker, let me extrapolate again > and make > > sure I'm not trying to do something that is just not going > to work. > > > > > > There seems to be no problem with evaluating that block from > within > > the ajax success, except when that block is send from a > TestCase and > > attempting to do an assert? > > > > > > ------ > > > > > > testFetch > > | library | > > > > library := FetchedCollection > > on: Array new > > at: 'http://localhost/couchdb/recipes/_all_docs'. > > > > > > self assert: library isEmpty. > > library fetchOnSuccessDo: [ self assert: library notEmpty ]. > > > > > > ------ > > > > > > Should that work? If so, I'll work up that simple case for > the issue > > tracker. > > > > > > If I just plug something simple into that block instead the > block > > stays defined and gets evaluated, e.g. > > > > > > ------ > > > > > > library fetchOnSuccessDo: [ window alert: 'hello there' ]. > > > > > > ------ > > > > > > Thanks. > > > > > > > > > > > > > > On Fri, Jan 6, 2012 at 5:59 AM, Amber Milan Eskridge > > <[hidden email]> wrote: > > I get that error, when I try to access a not-yet > stetted ivar > > (the ivar being undefined then). > > > > > > On Thu, Jan 5, 2012 at 9:16 PM, Nicolas Petton > > <[hidden email]> wrote: > > Hmm, that's odd. There's no reason why it > shouldn't > > work. And the JS > > equivalent works fine: > > > > function foo(fn) { > > jQuery.ajax({ > > url: '/', > > success: function() {fn()} > > }); > > } > > foo(function() {alert('it works!')}) > > > > Can you add a minimal example showing the > issue on the > > bug tracker? > > > > Cheers, > > Nico > > > > On Wed, 2012-01-04 at 09:12 -0500, Joel > Turnbull > > wrote: > > > > > > > > > Should I be able to execute a passed block > from > > within the success > > > block of an ajax call? > > > > > > > > > ------ > > > > > > > > > fetchOnSuccessDo: aBlock > > > > > > > > > jQuery > > > ajax: uri > > > options: #{ > > > 'type' -> 'GET'. > > > 'dataType' -> 'jsonp'. > > > 'success' -> [ :aJSONObject | self > > initializeFrom: > > > aJSONObject. aBlock value ]. > > > 'error' -> [window alert: 'error'] > > > } > > > > > > > > > ----- > > > > > > > > > javascript console says "Cannot call > method 'apply' > > of undefined", > > > trying to call _value there > > > > > > > > > > > > > > > > |
Free forum by Nabble | Edit this page |