ruby on rails, javascript block keeps loading in every page - javascript

I was doing a rails project and I added a small piece of 3rd party javascript which generated a button to my html.erb file in view, then I deleted it. However, the javascript (of course the button) keeps loading even if the source code didn't have that block. And more, whenever I created a controller/action, when I visit the page, the button will show up. Could anyone help me with that?

It's hard to help without seeing the code/error.
But I would recommend either:
Removing the javascript gem.
Searching and deleting the javascript.

Related

Issue with styled-components in "custom" single page application

I'm currently working on an old project, which has its "own way" of doing a single page application (does Ajax calls to an MVC application, gets the view, replaces the view client-side, appends styles and lots of other stuff!!), and although not ideal, currently I'm stuck with it!
I am trying to integrate an existing React application into this site, and what I'm doing is to use create-react-app and then build to create the bundles, and in the application, in the view begin returned from the server for a specific page, I'm putting script and link tags, pointing to my bundle files. It's worth noting that this server view is a partial ASP.NET MVC view, so my script and link tags are somehow part of the body.
I'm also using styled-components in my React application.
Now, here's the problem: when I first load the page I mentioned, my script is loaded, and I can see all my components being styled properly, but when I navigate in the existing custom SPA application, at some point, styles related to styled-components are messed up, and the only way to get them back is to reload the page.
I was inspecting the page, and I saw that styled-components is doing things with a custom link created in the head, and I see data-styled-components attribute being populated with custom class names as my components are loaded, but when the problem arises, in Chrome Developer Tools, I see that the link tag flashes as if it's changed, but it stays the same.
I have attached a GIF of the tag:
- It starts with the initial page load
- I navigate away and come back and I see more classes being appended
- I repeat the step, and I only see that it flashes
I know the post is already long, but any help is deeply appreciated. Is it possible that, with the current infrastructure, it has something to do with the fact that whenever I come back to the page, a script tag is sent from the server pointing to my React bundle?
Thanks to Max Stoiber for answering in this GitHub issue:
The reason for this behavior is exactly what I mentioned at the end of the question: every time the page is loaded, a script tag is sent from the server, containing the bundle, which in turn causes a new instance of styled-components to be created; this is not supported in styled-components, and that was the issue

Refreshing a HTML page with Java

I'm working on an Automation project using TestNG. I have created a Listener that updates a HTML file every time there is a test passed/failed/skip etc.
The only issue I have is that if I want to see these changes I have to manually refresh the HTML page.
Is there any code I can use within Java to automatically refresh a HTML page whenever a change is made to it or just refresh every second once the program is running?
EDIT: Seen that its mostly javascript this is done through so some advice on how to integrate JS into my Java class would be beneficial also, thanks.

JQuery Mobile: <script> tags do not show up but code runs

I'll refer to this ticket as step in the right direction for what I need:
jQuery mobile not loading new page scripts
One of the answers states that any code NOT nested in the first $([data-role=page]) tag in jQuery mobile will NOT show up in the html. I don't know if maybe this is a browser quirk or not but regardless, the code IS getting run despite it NEVER showing up. I find this difficult if I want to debug the js code since I can't add break points to any of it.
I've also had a problem with using the Jquery autocomplete plugin as it only works ONE time and then after submitting the form and returning the the form it no longer works. I believe this is because the page (well a partial piece of it by jquery mobile) gets reloaded and the autocomplete plugin is no longer bound to my textbox. I've tried using the live and on methods to make sure they get rebound but this doesn't work.
Can any javascript/jquery mobile geniuses out there help me out with this problem? Thanks!

weird problem with aspx page closing automatically

First I am new to the asp .net world and am trying to figure out a weird issue that I am having. Any suggestions or comments are welcome.
I have a page that has a form and on submit I launch another aspx file that exists in the same directory.
The problem is the aspx file is shown and the file closes immediately!.
Howewever, the weird part is if I make any modifications to the aspx file and save it and then run my application it works fine ONLY THE FIRST TIME!? any subsequent submit actions launch the aspx page but then the aspx file immediately closes.
But after I make some modifications to the aspx file..(simple ones) it launches correctly the first time.
I realize that this is very little info to go on and I am not even sure if I have got my point across...but any suggestions on how to debug this will be helpful.
We are targetting .net version 4.0 and using IIS7.
I am thinking that the asp worker process is doing something weird like checking for timestamps and closing it?! Not sure tho.
Any help is appreciated.
ASP.Net webforms don't use the form in quite the same way as regular HTML forms. All you need in your form tag is
<form runat="server">
If you want to pass the user onto another aspx page you can use the Response object:
Response.Redirect("~/pages/SomeOtherPage.aspx");
or (Server.Transfer - read up on the differences)
Server.Transfer("~/pages/SomeOtherPage.aspx");
If you want to open a page in a new/pop-up window or similar you'll need to do so using JavaScript
window.open('/pages/SomeOtherPage.aspx') [There are overridden versions of this method]
You can use the forms PostbackUrl property too, but this will also keep the user in the same browser window. More info here.
HTH

Pagination with special loading function?

I was searching for a script or at least a code snippet but haven't really made any progress. Anyway, I'm looking for a script that works like a simple pagination javascript but it should be accessible by linking from anywhere in the document and by calling it with the URL (e.g. on www.abc.de/default.html#thirddiv the third page of the pagination is displayed). Further, the contents should be loaded upon request (when the user clicks on the link and enters the specific page of the pagination), so that cookies, that have been set or deleted in the same document earlier can be used later without reloading the entire page. Something like that is used on Facebook for calling contents and loading them.
I've found a script on CSS Tricks called BetterBlogroll but I don't really get my mind into this. A pagination script from DynamicDrive is already working very well on the page but my problem is that there should be running three of them on the same page and as I said, the content should be loaded upon the user's request.
The script I'd need does not has to be with loads of CSS, the best way would be plain javascript and only the required CSS and HTML data. Anything else just disturbs. If anyone can help me out here, I'd be very thankful.
Check out Ryan Bates's Railscasts #174 and #175. These two are not rails specific, and explain this well.

Categories

Resources