This is not a question about a bug in my code, but a general one about how source code is refreshed in browsers. It does relate to debugging code so I think it's okay to ask here.
Essentially I have a rails app which renders partials using ajax. I'm trying to do some debugging, but the source code viewable in the browser (Chrome/Saf/FF) does not update when the partial is rendered, making it hard to debug the markup generated by the partial. Is there a way of accessing the partial code through the browser?
I have dynamically generated id tags and want to have a look at what's being produced.
Press F12
Go to "Network" tab
Click "XHR" amongst others like "All", "JS", "CSS", etc.
Visit the page and do the AJAX call
Click the new Network request that will show right after
Click "Preview" / "Response" tabs (whichever you need to inspect) amongst others like "Headers", "Cookies"
I think your question is pretty bad, but I'm not one to downvote.
I googled "see dynamic content in source" and got the answer, jest because I wanted to "let me google that for you", but SO forbids it :(
Unless I'm wrong about what you're asking, any dynamic content is displayed in browser's developer tools, which in FF is under F12 in inspector.
Related
Have been bashing my head against the wall for a good day and a half now. Did everyone abandon old fashioned page structures to go to jQuery Mobile?
I have a webpage, tracks legislation. Main navbar goes as such:
/bills/list, /legislators/list, /committees/list
Where each link is rewritten into
index.php?category=$1&detail=$2
so /bills/list translates to
index.php?category=bills&detail=list
But when I load a page from the navbar, using an a href tag, the pages load all nice and easy using the AJAX loader, but the newly loaded pages 1. don't run scripts, and 2. don't display any formatting. This is a problem.
All the suggestions I have seen say to .bind something or .refresh or .trigger without any context of where that goes, and everything I have tried in that vein has frustrated me to no end.
Please help! And by the way, if I just data-ajax=false everything it works perfectly. But I want the quick loading that ajax gives! I just don't understand how it works and there are really no good pointers on the web I could find.
Code in this pastebin: http://pastebin.com/9jMxV0B6
You can see some artifacts of my struggling to get the thing working.
From what I gather, you shouldn't call new pages via a href, but then why the hell does jqm use href's for its nav menu? Is that supposed to call a function or something?
"But when I load a page from the navbar, using a basic old fashioned a href tag, the pages load all nice and easy using the AJAX loader, but the newly loaded pages 1. don't run scripts, and 2. don't display any formatting. This is a problem."
That happens because JQM ignores all the headers in all other pages besides the first page that loads. So if you want to do any changes to the page use page events, place them In first page.
I had problems understanding it also. Here is a link to my previous post that explains it a bit: How do I enable onload in jQuery mobile (open page both from link & load)?
Hope it clears some things for you. My recommendation for you is to do two simple pages and test simple URL functionality.
I'm having a bit of an issue linking to a web app in my Rails application. Basically, I have a layout for the application, made of a header, sidebar, and main_content, and I want to be able to open the web app in the main window, sort of like a frame would do. How do I go about this? I tried using a simple link_to command, but that opened a new window, even when I included the :target parameter. I tried to set up a controller for it, and use that, but I couldn't find a way to link it to the app. Note that while I do own the app, I can only access it through a URL: I don't store it locally.
Sorry if this is an amateurish question, I'm still learning rails, and I'm very much in the beginner stage.
Assuming that the link you're using is to a full webpage rather than a fragment that's designed to be used inside another page, your best bet is an iframe embed.
All link_to does is render a regular hyperlink, and that will always load a new page (whether it's in a new window, tab, or replaces the current page).
If one uses remoteFunction or one of the the Grails Ajax capabilities, rendering a template to update a portion of a page, how does one see any additions made to the Javascript functions associated with the resulting page in Chrome or Firefox?
In Chrome, one is able to see the updated page/DOM via going to their Tools -> Developer Tools menu item, then selecting "Elements". There, I'm able to use the magnifying glass to select a portion of the updated page that I want to see. But, how do I also see the additional Javascript functions added to the page.
NOTE: Originally this question requested to see both html element content and Javascript content. Karthick AK's answer handles both.
In Chrome->Developer tool-> Network tab,
For each request being sent the response obtained can be seen in the Response tab. The rendered content can be seen in here.
Similiar option exists for firefox/firebug.
Another ajax gotcha i have experienced is, sometimes the ajax requests are cached and hence onclick the content is served from the cache and not an actual requests hits the server. This is more prominant in Old IE browsers
I have a list of links that users can click. When a click is made, I want to increment a counter (to track how many users clicked that link) and then open the link in a new window.
Right now, in the 'show' method method, I can do all that except the "new window" thing. Is there a way to achieve this in pure rails or do I have to do put some additional javascript to launch an ajax request (for the incrementation) and then open the link in a new window?
thanks,
Pierre
I would think the easiest solution would be to just have your link contain
target="_blank"
The window would open, go to your counter page, and get redirected to the correct page
You need to use AJAX, either to return javascript from the server or just a success code, and then open in a new window from javascript.
HTTP provides no way to open a new window.
A note! Be SURE you're a tags still have hrefs pointing at the URLs for your SEO!
Good luck!
A simple javascript may do:
window.open('filename.php?var=' + varvalue, 'resizable=1, scrollbars=1, left=80,top=60, width=650, min-height=400');
If you are using any jquery libraries, you can look into modals.
I do know about how to do this in Rails.
I am using version 14.67.9 of TembeddedWB in a project in delphi 2007. I use TembeddedWB in combination with loadfromstring. That all works like I want it to but when clicking on a link in the page it goes to a page I am not expecting. If for instance the page is on a particular IMDB result site and one clicks on the link the browser goes to about:/title/tt1041829/. I guess I forgot to set some extra property or I am doing something else wrong. If somebody here can point me in the right way i would appreciate that.
It looks like the browser's current URL is not updated and the default "about:blank" is used. I guess this may happen when you don't navigate to the web site directly by Navigate or Navigate2 method but load the HTML from a local file or stream.
Edit: I see, you are using LoadFromString which confirms that.
In that case, it should be possible to use OnBeforeNavigate2 event to fix the URL.
The problem is that the web page you are accessing uses relative links and the reference point that it would be relative too is your loadfromstring which loads through the "about:blank" page. Another way of fixing this would be to inject a <BASE href="http://www.originaldomain.com/originalpath"> tag in the HTML header (between the <HEAD> and </HEAD> tags) which points to the location the page was accessed from. This will tell the browser where relative tags start from and will fix the problem without requiring inspection of every link.