Polling change on rails with railscasts revised - javascript

I am trying to follow polling for change but i get the following error
Uncaught TypeError: Object [object global] has no method CommentPoller
Here the code in my comment.js.coffee file
# Place all the behaviors and hooks related to the matching controller here.
# All this logic will automatically be available in application.js.
# You can use CoffeeScript in this file: http://jashkenas.github.com/coffee-script/
#CommentPoller ->
poll: ->
setTimeout #request, 5000
request: ->
$.get($('#comments').data('url'))
jQuery ->
if $('#comments').length > 0
CommentPoller.poll()
What i am doing wrong?
Thank you

Try changing the first line
from
#CommentPoller ->
to
CommentPoller =

Related

issue with $cordovaContacts

i'm new in stackoverflow forum and i decide to create this topic to solve a problem wich i'm stuck for 2 weeks.
I have the following :
Visual Studio Android Emulator
Ionic 1 project created with the tabs pattern.
I'm trying to use the ngCordova contacts module ( $cordovaContacts ) to retrieve the phone numbers of the contacts. The problem is that there is an error with the "navigator" object. I found that there is not possible to acces the fields of these object ( functions , app , contacts , splashscreen ) so when i call to $cordovaContacts.find(...) it shows the error : "Can not find property find of undefined" . I invested some time debugging and when i use :
console.log(navigator);
The console shows:
[object Object]
services.js (21,15)
CordovaNavigator
_ {_
_ [functions]: ,_
_ proto: { },_
_ app: { },_
_ contacts: { },_
_ splashscreen: { }_
_ }_
But when i print navigator.contacts object it shows undefined
I also tried to use navigator.CordovaNavigator but is also undefined.
This code is called when loading controllers.
I have no idea why it shows that navigator has an atribute contacts and then when i call it it shows UNDEFINED . Maybe i need to stablish some acces rights ??.
I'm really lost so anything you tell me will help. Thanks a lot.
If you are trying to fetch the contacts on controller load (means, that you don't trigger it manually inside another method or via a timeout / interval), you'll need to wrap it with the ionicPlatform.ready() method, else the plugin isn't ready at that point.
ionic.Platform.ready(function(){
$cordovaContacts.find().then(function(allContacts) {
$scope.contacts = allContacts;
});
});

How to fix my ReferenceError

I've got a WordPress website I've been working on for a project of mine, the website is not nearly finished, On the website I have a button "Create A Clan" Which uses Visual composer (A plugin) I've reached out to WP Support with no aid, When I click on the "Create A Clan" Button, The visual composer just loads, and loads. I hit "F12" To try to see what is going on, and I have this error in the panel.
"Uncaught TypeError: undefined is not a function
this.activities_list[i].call(window);
Uncaught ReferenceError: i is not defined(anonymous function) # VM922:1InjectedScript._evaluateOn # VM921:883InjectedScript._evaluateAndWrap # VM921:816InjectedScript.evaluate # VM921:682.
I have no idea what the above means. It tells me that the error is inside of my "vc_Page_Editable.js" folder, within my theme. On line 292.
window.vc_google_fonts();
this.collectScriptsData();
this.loadInlineScripts();
this.loadInlineScriptsBody();
for(var i in this.activities_list) {
this.activities_list[i].call(window);
}
I can add the ENTIRE files contents if needed.
It looks like there is an issue with the list and one of the elements or properties in the list is undefined, so I would say safest bet is to check if that's the case and skip to the next element.
for(var i in this.activities_list) {
if(!i || !this.activities_list[i])
continue;
this.activities_list[i].call(window);
}

Zombie.js with Behat and Mink

I've been having problem after problem with getting Behat to work with Zombie.js. The problem I've got now is actually within the Zombie.js module (before, the errors were in the link between the two).
The error looks like so.
[RuntimeException]
Server process has been terminated: (8) [
url.js:107
throw new TypeError("Parameter 'url' must be a string, not " + typeof url)
^
TypeError: Parameter 'url' must be a string, not undefined
at Url.parse (url.js:107:11)
at urlParse (url.js:101:5)
at Object.urlResolve [as resolve] (url.js:405:10)
at History._resolve (/Users/nathanielh/www/website/node_modules/zombie/lib/zombie/history.coffee:201:20)
at History._assign (/Users/nathanielh/www/website/node_modules/zombie/lib/zombie/history.coffee:209:18)
at /Users/nathanielh/www/website/node_modules/zombie/lib/zombie/browser.coffee:326:30
at Browser.withOptions (/Users/nathanielh/www/website/node_modules/zombie/lib/zombie/browser.coffee:105:14)
at Browser.visit (/Users/nathanielh/www/website/node_modules/zombie/lib/zombie/browser.coffee:320:12)
at Socket.eval (eval at <anonymous> (/private/var/folders/fv/fp4xrfnx7kzfq2bqzywq5p9w00010f/T/mink_nodejs_serverSZBH0W:43:10), <anonymous>:2:9)
at Socket.<anonymous> (/private/var/folders/fv/fp4xrfnx7kzfq2bqzywq5p9w00010f/T/mink_nodejs_serverSZBH0W:43:5)
]
I've found that in history.coffee, the resolve function is trying to use an array element that doesn't exist.
// history.coffee
_resolve: (url)->
if url
return URL.resolve(#_stack[#_index]?.url, url)
else # Yes, this could happen
return #_stack[#_index]?.url
That reference to #_stack[#_index] resolves to undefined, which is then being passed into URL.resolve, which is then causing the error.
Any idea why this would happen?
Update
I've noticed that #_stack is empty, and #_index is -1. This shouldn't be possible, right?
The zombie driver breaks with node version 0.8.24 (0.8.23 works ok). I believe this is due to the change:
2013.06.04, Version 0.8.24 (maintenance), c1a1ab067721ea17ef7b05ec5c68b01321017f05
* url: Properly parse certain oddly formed urls (isaacs)
A similar change (made on the same day) appears to have been made in 0.10.10 (although I've not studied the commits directly).
2013.06.04, Version 0.10.10 (Stable), 25e51c396aa23018603baae2b1d9390f5d9db496
* url: Properly parse certain oddly formed urls (isaacs)
I would recommend reverting to 0.8.23 or 0.10.9 in order to get this working. If you're not already using it I recommend nvm to manage your node installations.
Same issue when trying to simulate a $nodeElement->mouseOver() with Mink/Behat/Symfony2.1
TypeError: Parameter 'url' must be a string, not object
at Url.parse (url.js:107:11)
at urlParse (url.js:101:5)
at Object.urlResolve [as resolve] (url.js:405:10)
at Object.iframe.setAttribute (/usr/lib/node_modules/zombie/lib/zombie/jsdom_patches.js:164:43)
at attrCopy (/usr/lib/node_modules/zombie/node_modules/jsdom/lib/jsdom/level1/core.js:331:14)
at Object.core.Node.cloneNode (/usr/lib/node_modules/zombie/node_modules/jsdom/lib/jsdom/level1/core.js:636:18)
at Object.core.Node.cloneNode (/usr/lib/node_modules/zombie/node_modules/jsdom/lib/jsdom/level1/core.js:706:37)
at Function.jQuery.extend.clone (/js/2225e47_jquery-1.8.2_2.js:6222:17)
at Function.jQuery.extend.parseHTML (/js/2225e47_jquery-1.8.2_2.js:501:31)
at jQuery.fn.jQuery.init (/js/2225e47_jquery-1.8.2_2.js:131:24)
at jQuery (/js/2225e47_jquery-1.8.2_2.js:44:10)
in /js/45a7194_jquery.jqModal_9.js
Node version is v0.10.15. Still digging for answers.

Object has no method 'call' when setting Backbone Model from Trigger

So, I just spent about 3 hours trying to debug this nasty thing and I'm at wits end.
What I'm trying to do is fairly simple. I'm working with a search query (string) and trying to set a global model with its attributes. However, when I'm moving to a different view, I want the model to clear out these attributes, or of course when they enter a new search query, have the event fire again. I'm trying to use the Backbone Marionette Wreqr / Event Aggregator to manage the events here.
I don't know if it's because I'm using requirejs, or not scoping things correctly, but I'm hitting this very confusing error:
Uncaught TypeError: Object #<Object> has no method 'call' backbone.amd.min.js:1
f backbone.amd.min.js:1
e.Events.trigger backbone.amd.min.js:1
i.extend.set backbone.amd.min.js:1
(anonymous function) app.js:42
f backbone.amd.min.js:1
e.Events.trigger backbone.amd.min.js:1
Application.searchRoute app.js:81
(anonymous function) backbone.amd.min.js:1
(anonymous function) backbone.amd.min.js:1
w.some.w.any underscore.amd.min.js:1
i.extend.loadUrl backbone.amd.min.js:1
i.extend.navigate backbone.amd.min.js:1
i.extend.navigate backbone.amd.min.js:1
SidebarLayout.search sidebar.js:177
(anonymous function) sidebar.js:3
x.event.dispatch jquery.min.js:5
y.handle
And here's some of my application code (my main controller). As you can see, I'm trying to set up the app.searchResult model with these other parameters from the searchRoute method.
What's so bizarre is that it works the first time the page loads, but when I attempt to use router navigate or do anything but refresh the page, it fails.
I tried using #searchResult instead, tried adding a , # after my trigger call, and all sorts of other things. What's stranger is that inside that scope, app.searchResult is available to me. And as soon as I remove the set call from there, the error doesn't happen anymore, so I'm thinking it must be that?
define [
'backbone.marionette',
'global/layouts/home',
'global/layouts/layout',
'search/models/search-results',
'search/collections/panels',
'global/collections/categories',
'global/collections/stores',
'global/collections/searchResults',
'search/views/panels',
'apps/router'
], (Marionette, homeLayout, subpageLayout, SearchResultModel, PanelsCollection, CategoriesCollection, StoresCollection, SearchResultsCollection, PanelsView, Router) ->
class Application extends Backbone.Marionette.Application
onInitializeAfter: =>
# Main Region
#addRegions
mainRegion: '#app'
# AppRouter
#router = new Router controller: #
# Request Response / Vent
#reqRes()
#appVent()
# Global Search Result Model
#searchResult = new SearchResultModel()
Backbone.history.start
pushState: false
root: ""
searchRoute: (query, params) ->
params = $.extend params, text: query
#vent.trigger "search:setParams", params
#subpageLayout = new subpageLayout()
#mainRegion.show #subpageLayout
appVent: ->
#vent.on "search:setParams", (params) ->
app.searchResult.set("params", params)
#vent.on "sidebar:reset", ->
app.searchResult.set("params", null)
I can send more code if you like, but the idea is to use a custom trigger like sidebar:reset to clear out these parameters. I'm also listening to some model events (all of that stuff is working great from within the context of the view and when I don't mess with the event aggregator).
Thanks in advance for your help. You have no idea how many hours I just spent on this!

Uncaught TypeError: Property '$' of object [object Window]

I've been working on a site recently that is now coming up with jQuery errors!
It has been behaving fine until recently when I have noticed these errors in chromes console. These seem to be coming up within the google hosted jQuery. I've tried using previous versions of jQuery as well but it keeps showing the errors.
It's online at https://www.upsandgeneratorparts.com/auction/
the header file is http://pastebin.com/PiKigvhg
This is the error that is showing:
Uncaught TypeError: Property '$' of object [object Window] is not a function
(anonymous function)
e.extend.globalEval jquery-1.7.2.min.js:2
e.extend.globalEval jquery-1.7.2.min.js:2
f.fn.extend.domManip jquery-1.7.2.min.js:4
e.extend.each jquery-1.7.2.min.js:2
f.fn.extend.domManip jquery-1.7.2.min.js:4
f.fn.extend.append jquery-1.7.2.min.js:3
f.fn.extend.html jquery-1.7.2.min.js:4
e.extend.access jquery-1.7.2.min.js:2
f.fn.extend.html jquery-1.7.2.min.js:4
f.fn.extend.load.f.ajax.complete jquery-1.7.2.min.js:4
f.Callbacks.o jquery-1.7.2.min.js:2
f.Callbacks.p.fireWith jquery-1.7.2.min.js:2
w jquery-1.7.2.min.js:4
f.support.ajax.f.ajaxTransport.send.d jquery-1.7.2.min.js:4
Is there a way of using noconflict to sort this or another handy function or am i just missing something out completely!
Oliver
You are using noConflict which sets $ to undefined, hence it's no longer a function.
Do not use .noConflict() unless you are 110% sure of what you are doing. It's technically completely useless function.
If you use (which you are) $.noConflict you can no longer access the $ object.
Hence, either don't use it, or always use the jQuery object instead of $.
On the source of the page you supplied I noticed this at line 737:
$(document).ready(function() { ...

Categories

Resources