Accounts.ui.config: Can't set `passwordSignupFields` more than once - meteor-accounts

In one of my react components, I have this
<a href={'/application/' + username +'/' +appid}>My Application</a>
When I click on that link, I get the javascript error Accounts.ui.config: Can't set 'passwordSignupFields' more than once.
However, when I go to the directly to the url http://192.168.0.110:3000/application/john/X93ajdsfj by pasting the url into the browser address bar, then the page loads without errors. I only get an error when I load the page by click on the anchor tag.
I suspect that when I click on the link, I'm probably not doing a full HTTP page reload, and only parts are reloaded, and this javascript found in my myproject.jsx gets fired again:
// This code is executed on the client only
Accounts.ui.config({
passwordSignupFields: "USERNAME_ONLY"
});
I am completely new to meteor. What is the best way to avoid this problem?

I moved the code out of the React component and into the main .jsx file of the meteor project and wrapped it with a Meteor.isClient if statement like so:
if(Meteor.isClient)
{
// This code is executed on the client only
Accounts.ui.config({
passwordSignupFields: "USERNAME_ONLY"
});
}

Related

casperjs cant click popup

My code:
casper.waitForSelector('.single_like_button.btn3-wrap .btn3',
function success() {
this.click('.single_like_button.btn3-wrap .btn3');
}
);
Returned:
TypeError: 'undefined' is not an object (evaluating 'window.angular.version')
https://s.ytimg.com/yts/jsbin/www-en_US-vfl2odRpD/angular_base.js:167
https://s.ytimg.com/yts/jsbin/www-en_US-vfl2odRpD/angular_base.js:225
the button when clicked, will open a second tab window, like a popup,
when the second window finished its works, it will close automatically and transfer data back to 1st window.
I dont know if this process had used angular js?
and do i need to install angularjs and how?
beacuse the error seemed related to angularjs
the popup url is inside a javascript's function, i dont know how to scrape it
I dont get the popup url, so i dont know how to use "waitforpopup"
but even if i can get the url, i still have to click the button in order to the correct data transfer. I have used clickLabel("Subscribe", div) , also not working.
Any advices?
I've had issues with waitForSelector before.. Although I'm not familiar with your html/js, why not try the following in place of your code above to do a quick sanity check. This will give you a better idea of what's happening.
this.wait(5000,function(){ // use wait (5 secs) instead of waitForSelector
// log the el to see if it exists at this point
console.log($('.single_like_button.btn3-wrap .btn3').length + " els found");
// click dat
this.click('.single_like_button.btn3-wrap .btn3');
});

Enable browser action for an event in Google chrome

I am writing a chrome extension for capturing the URL. This is the code for my js file.
chrome.tabs.getSelected(null, function(tab) {
myFunction(tab.url);
});
function myFunction(tablink) {
alert(tablink);
}
Now i can get the URL alert for the page by explicitly clicking on the browser action. I need it to popup the alert whenever i click on any tab in my browser.
Could you please let me know how to proceed with this?
PS: I am sure i have to use some kind of event listener.
chrome.tabs.getSelected is deprecated since Chrome 33. Use chrome.tabs.query instead if needed.
Base on your need to make popup the alert whenever you click on any tab in your browser. You can use chrome.tabs.onActivated.addListener.
The code I created is as below and it works with me. It popup the alert of current page's url whenever you click on any tab in your browser.
chrome.tabs.onActivated.addListener(function(activeInfo) {
//alert("popup");
chrome.tabs.get(activeInfo.tabId, function(tab){
alert(tab.url);
});
});
Also keep in mind to add "permissions": ["tabs"], in your manifest file since it requires access to the url. See here:https://developer.chrome.com/extensions/tabs

Wicket AjaxLink javascript handler shows strange behaviour

I have a ListView that displays a list of Panels, one below the other. Every panel features a button (implemented via AjaxLink) that closes the panel and removes it from the list.
This is how the ListView is initalized and how the panels are created:
panelsList = new ArrayList<MyPanel>();
pnlContainer = new WebMarkupContainer("pnlContainer");
ListView<MyPanel> pnlItems = new ListView<MyPanel>("pnlItems", panelsList) {
#Override
protected void populateItem(final ListItem<MyPanel> item) {
item.add(item.getModelObject());
item.add(new AjaxLink<Void>("pnlClose") {
#Override
public void onClick(AjaxRequestTarget target) {
panelsList.remove(item.getModelObject());
target.add(pnlContainer); // repaint panel container
}
});
}
};
pnlContainer.setOutputMarkupId(true);
pnlContainer.add(pnlItems);
add(pnlContainer);
This works so far - the actions that trigger adding new panels (usually also AjaxLinks) do what they should and the new panel is added and displayed correctly. But I have problems getting the close button to fully work.
Please see the following steps:
1) I start the server and navigate to the main page. The ListView is initially populated with one panel.
Close-button-code of this panel:
<a wicket:id="pnlClose" id="pnlClose7" href="javascript:;">Close</a>
Searching the page code for pnlClose7 finds the following javascript code that makes the button work as expected:
Wicket.Ajax.ajax({"u":"./?0-1.IBehaviorListener.0-pnlContainer-pnlItems-0-pnlClose","e":"click","c":"pnlClose7"});;
Note: I do not press the button now, if i would, it would work as expected (thoroughly tested).
2) I trigger an action that opens a second panel. The panel is displayed below the first one as expected.
Close-button of the first panel:
<a wicket:id="pnlClose" id="pnlClosef" href="javascript:;">X</i></a>
Close-button of the second panel:
<a wicket:id="pnlClose" id="pnlClose10" href="javascript:;">X</i></a>
But now, neither searching for pnlClosef nor pnlClose10 finds some javascript code. The buttons (both!) do not work. I can still find the javascript code for pnlClose7.
3) I reload the page via pressing F5.
The button IDs change to pnlClose1a and pnlClose1b. Both IDs have javascript counterparts and work.
4) I press the first button (upper panel, ID pnlClose1a). The panel is closed as expected.
The remaining button's ID changes to pnlClose1c, again without a javascript counterpart. Javascript code for pnlClose1a and pnlClose1b is still present.
To make a long story short, the javascript handlers for my AjaxLinks seem to have shyness issues and only appear after I press F5 or reload the whole page in any other manner. I guess thats because repainting the pnlContainer changes the IDs of the current panels - but why is the linked javascript not updated at the same time? Is there anything I can change in my code to update the whole page without completely reloading it?
Wierd thing is that I am pretty sure this worked before... But I checked the whole class history and can't find any major change that would have triggered that. The ListView-code is mainly static since I added it.
I was had similiar problem. if you have any hardcoded javascript code in your page or panels html file (using <script> tag) remove it and set that js code in renderHead of your panel.

facebook like button on my site only shows up after you refresh the page. does it have to do with all.js

I used code from
http://developers.facebook.com/docs/reference/plugins/like/
to add a like button on the site. I have the script tags right after the body as described and the div further down by my header, but when I load the page, the like button is not there. but if I hit refresh its there. my guess is that the all.js is taking too long to load and its missed somehow on the 1st load. on the 2nd refresh, I assume the js is cached and things work as expected.
any idea how to wait on this? I have tried putting the script in the head, at the bottom.
When you say "I have the script tags right after the body", do you mean outside of the body? If so, try putting it in side the body, but after all other element inside of the body.
<body> ...other code ...other code ...other code
<script>Put your script here</script>
</body>

How can I hide like button or div from Firefox?

I am building a web page and I have included Facebook's Like button. Works great in all browsers but not in Firefox. When clicked in Firefox, it creates an endless loop of opening and closing a facebook login window. This is a known issue that Facebook isn't looking like it will correct anytime soon.
Can anyone tell me what code I might write to hide the like button (or a div containing the like button) from Firefox only? I've never written code to detect a browser and then have my site function a certain way. Not a javascript guru here. Thanks!
You can do this using the navigator javascript object, but it sounds like you have deeper problems if the facebook like button is causing an endless loop of window loads. You most probably have other errors in your code. The button should work fine in firefox.
Here's how to text for firefox using the navigator object,
if (/Firefox[\/\s](\d+\.\d+)/.test(navigator.userAgent)){
// user using firefox
}
This code parses the userAgent string, the string that defines the user's browser, of the navigator object. It looks for a string of the format Firefox/x.x or Firefox x.x.
This should work for you
<div id="likeDiv">
my div
</div>
<script>
if (navigator.userAgent.indexOf("Firefox")!=-1)
{
// Remove the element from the dom
var Node1 = document.getElementById('likeDiv');
Node1.removeChild(Node1.childNodes[0]);
}
</script>
Hope this helps