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).
Related
I'm using a Rails 6 template (Jumpstart Pro) that has the new stuff hotwire, stimulus, webpacker. It works OK for basic stuff... scaffolding new models and make CRUD forms, etc.
However one of my pages uses a vendor's javascript widget, which also requires jquery.
Neither Jumpstart Pro template nor its Forum have any up-to-date documentation or support for adding jQuery via webpacker (e.g., no support for adding jquery the "right way").
So I've added jquery to the one page that needs it via a good old fashioned script tags in the header
%script{:src => "//ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.js"}
followed by the vendor's javascript to initialize the vendor's widget, inside $(document).ready(function(){ init_code_goes_here }); so the widget has time to load to the page.
Works: If I type the page's url into the browser "localhost:5000/cool_page" or "mydev.ngrok/cool_page", it works fine.
Broken: But clicking a link IN the app to go to the page (via link_to "cool page", "/cool_page") does not work:
jQuery is loaded (I have a little "hello world" jquery script that un-hides a div to confirm jquery is loaded)
the vendor widget does not load properly (browser console says widget object is null)
But if I then refresh the page, everything loads fine.
So the page works if "loaded" but not it reached via another page.
From this I infer that the magic behind hotwire/etc is interfering with a proper load of the page when I navigate to it.
So, the question: in a hotwire-enabled Rails 6 app, is there any way to have a nav link that, when clicked, simply tells Rails... skip hotwire shortcuts, load this page for real?
I believe your issue is just that you need to restore default (non-Hotwire) link behavior. There are 3 ways to do that.
See this answer: https://stackoverflow.com/a/68657223/2648054
In short:
1: Set the data-turbo attribute to false.
2: Set the target attribute to "_top".
3: Move the link outside any Turbo frame. Any link inside a Turbo frame, without one of the above attributes, will be handled by Turbo by default.
I'm trying to integrate a vue.js application into a typo3 page.
I have a full functional TYPO3 instance where I can create own pages, edit the content and more. Now I want to add an existing vue.js application within this page.
Therefore I created an extension which added all necessary resources (js, css) and added an own content type which controls the integrations and configurations. The content type outputs a vue.js entry point. So far everything works. Smaller vue.js applications works as they should.
Now comes the challenge: When I want to create a more complex application which relies on the router functionality, I run into a problem.
Let's assume, I integrate my application into the page /shop and my application tries to render a product under /shop/product/some-id. This doesn't work. The URL processing is done by TYPO3 (as designed).
I tried to find a solution within the documentation but I'm not sure what I should search. I need a way to output the same page (/shop) regardless the following path. Does someone have a hint?
I found a solution. Within TYPO3 v8 is it possible to use the realurl extension for this purpose.
It is possible to define an own decode preprocessing function and analyse the current url.
$GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['realurl']['decodeSpURL_preProc'][] = RealUrlManipulation::class . '->decodeSpURL_preProc';
Within this method is it possible to change the url for TYPO3 inner processing and set it to an known url.
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.
I'm working on a project where I need to embed a very simple browser in a webpage using Ruby on Rails.
For example, if a user is on my website, he/she can click on a link for a different website, it will open it inside a small window in the same original website.
Same idea of an embedded browser in mobile apps.
Is it possible to do?
You can try to use the iframe tag
I am new to Symfony and I need to work to a large project with many themes to modify them. How can I find where actually is the theme file in which module, just looking at the HTML browser output? Or do I need to look somewhere else, routing for example?
What you want to do is use the Web Debug Toolbar.
Once you have that running on the page, using appname_dev.php, simple click the view link and it will show you which templates have been used. If you need to know which layout to use then use logs link, click none the sfPHPView.