partials

AJAX, Rails, and dynamic loading of forms.

I have a rails app that has picked up a bit of traction, but I have a serious headache to deal with. It's a basic sort of asset manager application - users upload their photos, .pdfs, videos, etc., and the system allows them to manage how that asset is presented. I started with a fairly standard rails view - just what gets generated by...

How to keep track of information over several calls to render :partial

I am using attribute_fu to render a nice block of rows for a particular table. <%= f.render_associated_form(@foo.bars, :new => 5) %> I would like to have the bar partial have some notion of a bit of state. (Because the notion is specific to the view, I do not want to externalize this to the Bar model itself and calculate it in the co...

Ruby on Rails - Trouble looping through partial using collection

I am having issues using the :collection command for a partial within a form I am creating in rails. I would ideally like to use the :collection command, so I can easily manipulate this section in my .rjs templates (the form will submit and reload the form when the check box is changed, it's a to-do list). This code works: <% for...

ASP.NET MVC Question - Form Posting, Partials & Efficiency

Hi There, (My first question, so hello all!) I am using C# and the ASP.NET MVC Framework Beta 1 and was wondering if this was the most efficient way to achieve two, form posting scenarios using a single partial and also how to get the edit mode working. The partial contains my html form code so it can be recycled in both an add and edit...

When to use Helpers instead of Partials

In a rails application, in which situation would you use a partial and when would you use a helper? I find both very similar, since they represent markup fragments. Is there a convention around this? which is the 'rails way' of using them? Thanks! ...

Same partial on multiple views returning to whatever view it was called from

I'm currently re-using a partial on two different views. View A View B The partial belongs to Model A but has an association with Model B so it is applicable to Model B as well. It contains a form and when data is submitted, it always redirects the user to View A. However, when I submit the form from View B, I would like to...

Asp.Net MVC. Updating user control (Shopping Cart) with Ajax

I want to implement a user control which represents a list of the current items in a user's shopping cart, and which is included from within the a master page. I want to add a product to the shopping cart; the shopping cart should be automatically updated with an asynchronous call (JavaScript framework is jQuery) when a user adds a prod...

strongly-typed partial views MVC RC1

having a problem passing ViewData.Model to the partial views. It always is defaulting to null even if I equate it to a result query. I cannot access the strongly typed data because the Model is null. My current code is this, ViewPage <asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server"> <% Html.RenderPartia...

Is there an analogue to Rails partials in VB .NET?

I'm new to VB .NET, and if possible, I'd like something like Rails partials - bits of HTML template that can be referenced in a page's script, possibly within a loop. I know there might not be anything like that. ...

Is it possible to put just a rails form element in a partial?

My app has a select box for users to choose a "venue". This select box is, as you would expect, in a form. I also have an action somewhere on the page that creates a new venue via AJAX. After the new venue is created, I would like to updated the venue select box to reflect this. My solution was to put the select box in a partial and ...

CodeIgniter or PHP equivalent of Rails partials and templates

In CodeIgniter or core PHP is there an equivalent of Rails's view partials and templates? A partial would let me render another view fragment inside my view, like have a common navbar.php view that I could point to inside my homepage.php view. Templates would let define the overall shell of an HTML page in one place, and let each view ...

Ruby/Rails 1&2: collection problem

Hey, I just began to learn ruby/rails. At the moment, I try to do an example of a german book "Praxiswissen Ruby on Rails", which is pretty old and written for Ruby on Rails 1. Anyway, I tried to do the examples with Rails 2. Now I have had problem for over a week. According to the book (Rails 1) I have to write in my controller: pa...

View Models (ViewData), UserControls/Partials and Global variables - best practice?

Hi I'm trying to figure out a good way to have 'global' members (such as CurrentUser, Theme etc.) in all of my partials as well as in my views. I don't want to have a logic class that can return this data (like BL.CurrentUser) I do think it needs to be a part of the Model in my views So I tried inheriting from BaseViewData with these m...

Are variables defined locally in a partial also visible to the invoking erb template?

If I declare local variables in a partial and then render the partial from another erb template, will the latter also have accces to those local variables? ...

Rendering a collection of different classes in Rails

I have a collection that contains instances of several different classes, and I want to render the partial for each instance. I can do this using the following code: <%= render @results %> My question is: How can I render the different partials in a different base directory? The above code will look for app/views/stories/_story.html.e...

Rails -- How to save HTML output of a HAML partial as a string to send to an external service?

Hey guys, first post here, hope you can help me out. We're generating a newsletter automatically every 24 hours using a rake task. There's a section at the top of the newsletter where an admin can put a customized message. The screen that the admin uses has a live preview of the newsletter (they were insistent on this), rendered using...

ZF: Using setObjectKey in partialLoop for only specific partials

I've figured out how to get models into partialLoops using the setObjectKey method of the PartialLoop helper. What I'm wondering if there is a way to specify that specific partial loops use the model key and other ones don't. Right now I think I have to do something like this: // sets the object key for ALL partialLoops $this->partialLo...

Partials and local variable

If we want to pass a collection to partial, we do like this: <%= render :partial => "post", :collection => @posts %> If we want to pass a single object within a custom variable, we do this: <%= render :partial => "item", :locals => { :item => @advertisement } %> Now what should I do to to pass a collection, "proxying" it through a ...

Using Ajax to Replace A Page Element Based on an Onclick Event

I'm reformulating this question as I'm understanding the issue better now. I have an application with four models: Users, Products, Varieties and Seasons. User has_many :seasons has_many :products, :through => :seasons has_many :varieties, :through => :seasons Product has_many :seasons has_many :users, :through => :seasons has...

Letting a template and multiple partials add to the layout

First off, let me say that I am familiar with content_for. It's not really what I'm looking for here. I want to allow a template and any number of partials to build up, say, a list of JavaScript files I want to load, and pass them up to the layout for it to process and add to the <head> area. I only want to load the files if the page ac...