how to load a partial view as a Modal in Ruby on rails? - ruby-on-rails-5

I have a partial view (in a haml file ). is it possible to load this as a Modal, when the page this contains loads, may be via javascript?
#content
.left.column
%p= some content

Related

How to know at render time what partials are being used in a Razor page in ASPNET Core?

I have an ASPNET Core (.net6) project with a main page layout that automatically includes styles and scripts in the page bases on the page file name. Example: if you have a page called me/details (the file being me/details.cshtml) and there is a file called wwwroot/me/details.css, a reference to it will be included by my layout page inthe head of the html. The same happens for script files, but at the end of the body
I wanted to do the same for partials views. I want to include specific styles and script file references in the html for any partial views being rendered in the page, without extra code in the partials. Is there any way to know at render time, or at least at the middleware level, what partial views are being used in a page?

How to render multiple root elements in Xamarin forms?

I want to render two pages in Xamarin. One is the main page and the other one is a footer page- they both are .xaml files. The only problem is that the footer uses a ThriveGmbH.BottomNavigationBar.XF imported NuGet class and the Main Page uses a content page class. When I try to use both classes inside a single script I get a "multiple root elements" error. Is it possible to render both pages or call the footer page inside of the main page? Thank you in advance.

Rendering an HTML file in rails

I am using CarrierWave to upload static HTML templates to certain user profiles on my webpage.
I am trying to render the HTML file on the user's home page once they log in. The Path for the HTML file after uploading is:
/uploads/profile/curation/8/User_Content.html
I'm new to rails and I thought I'd just be able to
<%= render /uploads/profile/curation/8/User_Content.html %>
to get the html to render, but I guess that only works for partials, which this is not.
Any advice?
You can use render_to_string. Please have a look over here. http://russbrooks.com/2009/11/18/embed-a-static-hmtl-page-in-a-rails-view
In your controller you can redirect to the page you want:
redirect_to "/uploads/profile/curation/8/User_Content.html"

:remote => true/data-remote on a form loaded via ajax

In my Rails app, I have a form that is loaded via Ajax using jQuery load method.
function load_sales_form(product_id) {
$("#sales_form").load("<%= url_for(:action => :show_sales_form) %>"/ + product_id);
}
The loaded form has a form_for tag with the :remote => true option and it does add the data-remote="true" attribute to the form.
But the form isn't submitted using Ajax when the user clicks the submit tag button. It works fine if the form is loaded in the standard, non-ajax way, but it the form is loaded via ajax after the document is ready, is does not submit using ajax, it submits as a standard form.
From what I studied so far, this happens because the rails.js file (which contains the stuff that allow data-remote forms to be submitted via ajax) does not apply it's features to html content loaded via ajax.
Is it possible to force rails.js file to apply it's features to content loaded via Ajax?
Same situation here. I found a solution.
Not the dynamic loading, but incorrect triggering of submit event was the cause in my case.
I had a Bootstrap modal with data-target and href attributes set. This causes the content inside a .modal-body to be loaded via AJAX from address specified in href.
The modal was pre-equipped with save button (outside of the loaded form), which called the submit like this.
$modal.find("form.loaded_form").get(0).submit(); // INCORRECT
The former only executes raw submit, but:
$modal.find("form.loaded_form").trigger('submit'); // CORRECT
does the trick.

Rails 3 render layout except for root_url

I want to have a different layout for the home page (root_url) than the other pages in my web app. I would like to be able to use <%= render 'layouts/pages' %> for pages that are not the home page. How do I go about doing this?
Majority
The best way to do this is to name the layout for the majority of your app layouts/application - this way, Rails will automatically assume this layout for that majority without you needing to do anything else.
Home
For your home page, you can add this line to the bottom of your controller action:
render :layout => "home"
This will tell Rails not to use application, but instead to point to your home/root page's layout, which in this case would be located at layouts/home.