Search Results

Search found 6941 results on 278 pages for 'drupal views'.

Page 73/278 | < Previous Page | 69 70 71 72 73 74 75 76 77 78 79 80  | Next Page >

  • Refactoring routes - serving different layouts

    - by dmclark
    As a Rails NOOB, I started with a routes.rb of: ActionController::Routing::Routes.draw do |map| map.resources :events map.connect 'affiliates/list', :controller => "affiliates", :action => "list" map.connect 'affiliates/regenerate_thumb/:id', :controller => "affiliates", :action => "regenerate_thumb" map.connect 'affiliates/state/:id.:format', :controller => "affiliates", :action => "find_by_state" map.connect 'affiliates/getfeed', :controller => "affiliates", :action => "feed" map.resources :affiliates, :has_many => :events map.connect ":controller/:action" map.connect '', :controller => "affiliates" map.connect ":controller/:action/:id" map.connect ":controller/:action/:id/:format" end and i'm trying to tighten it up. and I've gotten as far as: ActionController::Routing::Routes.draw do |map| map.resources :events, :only => "index" map.resources :affiliates do |affiliates| affiliates.resources :has_many => :events affiliates.resources :collection => { :list => :get, :regenerate_thumb => "regenerate_thumb" } end # map.connect 'affiliates/regenerate_thumb/:id', :controller => "affiliates", :action => "regenerate_thumb" map.connect 'affiliates/state/:id.:format', :controller => "affiliates", :action => "find_by_state" map.connect 'affiliates/getfeed', :controller => "affiliates", :action => "feed" map.root :affiliates end what is confusing to me is routes vs parameters.. For example, I realized that the only difference between list and index is HOW it is rendered, rather than WHAT is rendered. Having a different action (as I do now) feels wrong but I can't figure out he right way. Thanks

    Read the article

  • How do I get rid of extra lines in my output from Rails

    - by Dan B
    I am using Rails 2.1 to output tables from a database. But the output includes lots of extra lines and tabs. I am using a while loop with lots of nested if statements. I am also wrapping all of my non-output lines in <%- code -%. Any idea what might be happening and a solution? Thanks, ex: <tr> <td>Some data</td> <td>more data</td>

    Read the article

  • Is it possible to write a database view that encompasses one-to-many relationships?

    - by Brandon Linton
    So I'm not necessarily saying this is even a good idea if it were possible, since the schema of the view would be extremely volatile, but is there any way to represent a has-many relationship in a single view? For example, let's say I have a customer that can have any number of addresses in the database. Is there any way to list out each column of each address with perhaps a number as a part of the alias (e.g., columns like Customer Id, Name, Address_Street_1, Address_Street_2, etc)? Thanks!

    Read the article

  • MVC3 View For Loop values initialization

    - by Ryan
    So I have a for loop in my View that is supposed to render out the input boxes. Now inside these input boxes I want to put lables that disappear when you click on them. This is all simple. Now it's probably because my brain was wired for php first, and it has been difficult to get it to think in lambdas and object orientation, but I can't figure out how to do this: @{ for (int i = 0; i < 3; i++) { <div class="editor-label grid_2">User</div> Model.Users[i].UserFirstName = "First Name"; Model.Users[i].UserLastName = "Last Name"; Model.Users[i].UserEmailAddress = "Email Address"; <div class="grid_10"> @Html.TextBoxFor(m => Model.Users[i].UserFirstName, new { @class = "user-input" }) @Html.TextBoxFor(m => Model.Users[i].UserLastName, new { @class = "user-input" }) @Html.TextBoxFor(m => Model.Users[i].UserEmailAddress, new { @class = "user-input-long" }) @Html.CheckBoxFor(m => Model.Users[i].IsUserAdmin) <span>&nbsp;admin?</span> </div> <div class="clear"> </div> } } And initialize the values for the users. And you're probably thinking "Of course that won't work. You're going to get a Null Reference Exception", and you would be correct. I might need to initialize them somewhere else and I don't realize it but I'm just not sure. I've tried the [DefaultValue("First Name")] route and that doesn't work. I'm probably thinking about this wrong, but my brain is already shot from trying to figure out how to wire up these events to the controller, so any help would be appreciated!

    Read the article

  • Rails 3: How do I call a javascript function from a js.erb file

    - by user321775
    Now that I've upgraded to Rails 3, I'm trying to figure out the proper way to separate and reuse pieces of javascript. Here's the scenario I'm dealing with: I have a page with two areas: one with elements that should be draggable, the other with droppables. When the page loads I use jQuery to setup the draggables and droppables. Currently I have the script in the head portion of application.html.erb, which I'm sure is not the right solution but at least works. When I press a button on the page, an ajax call is made to my controller that replaces the draggables with a new set of elements that should also be draggable. I have a js.erb file that renders a partial in the correct location. After rendering I need to make the new elements draggable, so I'd like to reuse the code that currently lives in application.html.erb, but I haven't found the right way to do it. I can only make the new elements draggable by pasting the code directly into my js.erb file (yuck). What I'd like to have: - a javascript file that contains the functions prepdraggables() and prepdroppables() - a way to call either function from application.html.erb or from a js.erb file I've tried using :content_for to store and reuse the code, but can't seem to get it working correctly. What I currently have in the head section of application.html.erb <% content_for :drag_drop_prep do %> <script type="text/javascript" charset="utf-8"> $(document).ready(function () { // declare all DOM elements with class draggable to be draggable $( ".draggable" ).draggable( { revert : 'invalid' }); // declare all DOM elements with class legal to be droppable $(".legal").droppable({ hoverClass : 'legal_hover', drop : function(event, ui) { var c = new Object(); c['die'] = ui.draggable.attr("id"); c['cell'] = $(this).attr("id"); c['authenticity_token'] = encodeURIComponent(window._token); $.ajax({ type: "POST", url: "/placeDie", data: c, timeout: 5000 }); }}); }); </script> <% end %> undo.js.erb $("#board").html("<%= escape_javascript(render :partial => 'shared/board', :locals => { :playable => true, :restartable => !session[:challenge]}) %>") // This is where I want to prepare draggables. <%= javascript_include_tag "customdragdrop.js" %> // assuming this file had the draggables code from above in a prepdraggables() function prepdraggables();

    Read the article

  • ASP.NET MVC View Not posting back to Post method and expecting a parameterless Constructor?

    - by VJ
    Hi, I am trying to post back some data using a viewmodel i have created and it works for me for one of the projects.But I am doin this right now public ActionResult Foo(string userkey) { vm.Value="Xvalue"; return View(vm); } [HttpPost] public ActionResult Foo( MyViewModel vm) { // process input if (inputOK) string value=vm.Value return RedirectToAction("Index"); return View(); } public class MyViewModel { public string Value { get; set; } public SomeClass newobj {get;set;} } public class SomeClass { public int id{get;set;} public string str{get;set;} } So it on debugging never goes into the parameter method for Post although on the view i have added a form and a button that submits and the page inherits from the viewmodel.I get an error saying it expects a parameterless constructor how do I fix this ? . I wrote an post method with no parameters and it does go into that method

    Read the article

  • Pass existing model into AJAX PartialViewResult

    - by Joe
    I’m using AJAX to asynchronously update a partial view and need to pass the existing model into the partial view. Controller Action public ActionResult Edit(int id) { var vM = new MyViewModel(); // vM is viewModel return View(vM); } Edit View @using (Html.BeginForm()) { @Html.ValidationSummary(true) ... <span id = "Ship"> @Html.Partial("AJAX_Views/_Ship")</span> _Ship Partial View @model MyProject.ViewModels.MyViewModel <table class="detailtable" style="min-width:398px"> <tr> <th style="padding-left:132px" colspan="2"> <span class="editor-label">Shipping&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Address</span> <span class="editor-label" style="padding-left:55px"> @Ajax.ActionLink("Delete", "SHIPDEL", new AjaxOptions { UpdateTargetId = "Ship", InsertionMode = InsertionMode.Replace, HttpMethod = "Get" })</span> <tr><th style="min-width:152px"><span class="editor-label">Street:</span></th> @Html.HiddenFor(m => m.CmpAdrsSh.Id) @Html.HiddenFor(m => m.CmpAdrsSh.CompPersonId) @Html.HiddenFor(m => m.CmpAdrsSh.IsShip) <td><span class="editor-field">@Html.EditorFor(m => m.CmpAdrsSh.Street) @Html.ValidationMessageFor(m => m.CmpAdrsSh.Street) </span></td></tr> <tr><th><span class="editor-label">City:</span></th> <td><span class="editor-field">@Html.EditorFor(m => m.CmpAdrsSh.City) @Html.ValidationMessageFor(m => m.CmpAdrsSh.City) </span></td></tr> <tr><th><span class="editor-label">State:</span></th> <td><span class="editor-field">@Html.DropDownList("CmpAdrsSh.State", (IEnumerable<SelectListItem>)ViewBag._State) @Html.ValidationMessageFor(m => m.CmpAdrsSh.State) </span></td></tr> <tr><th><span class="editor-label">Zip:</span></th> <td><span class="editor-field">@Html.EditorFor(m => m.CmpAdrsSh.Zip) @Html.ValidationMessageFor(m => m.CmpAdrsSh.Zip) </span></td></tr> _ShipDel Partial View @model MyProject.ViewModels.MyViewModel <table class="detailtable" style="min-width:398px"> <tr> <th style="padding-left:132px" colspan="2"> <span class="editor-label">Shipping&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Address</span> <span class="editor-label" style="padding-left:10px; color:red">Marked for Deletion.</span></th></tr> <tr><td>To not Delete Select Cancel below!</td></tr> @Html.HiddenFor(m => m.CmpAdrsSh.Street) @Html.HiddenFor(m => m.CmpAdrsSh.City) @Html.HiddenFor(m => m.CmpAdrsSh.State) @Html.HiddenFor(m => m.CmpAdrsSh.Zip) Controller PartialViewResult Action public PartialViewResult SHIPDEL() { return PartialView("AJAX_Views/_ShipDel"); } I tried adding this.ModelState to the Action but then the view will not render. I'm guessing I somehow have to pass the model to the SHIPDEL Action first. I couldn't find an @Ajax.ActionLink overload that would allow this. public PartialViewResult SHIPDEL() { return PartialView("AJAX_Views/_ShipDel", this.ModelState); } In the _ShipDel Partial View I need to expose the CmpAdrsSh properties so the model validates in the POST Action. The model is empty at this point. How do I pass the existing vM model into the _ShipDel partial view? Thank you,

    Read the article

  • How to save a custom cookie

    - by xRobot
    Is there a way to save a cookie that is available on other site ? For instance I have my django project on http://www.example.com and I want that django saves a cookies for a site written in PHP on http://site.Idontknow.com . Is this possible ?

    Read the article

  • Using Django view variables inside templates

    - by William
    Hi, this is a rather basic question (I'm new to Django) but I'm having trouble using a variable set in my view inside my template. If I initialize a string or list inside my view (i.e. h = "hello") and then attempt to call it inside a template: {{ h }} there is neither output nor errors. Similarly, if I try to use a variable inside my template that doesn't exist: {{ asdfdsadf }} there is again no error reported. Is this normal? And how can I use my variables within my templates. Thanks!

    Read the article

  • Django Datetime field question

    - by Shehzad009
    Hello I have been having a problem with django while trying to work with datetime. In my webapp I have a table like so when I run server. ID Owing 1 -100 (All the same value) 2 -100 3 -100 . . . . . . It has in one column Invoice id and the other owing. One-one relationship as well. sow for example owing value for 1 is 100. Unfortunately, this is where it all goes wrong because throughout column (Owing), it is giving me the owing value for ID=1. I want each ID to give me their owing value. Here is my view. I also wonder if I may need a for loop somewhere as well. def homepage(request): invoices_list = Invoice.objects.all() invoice_name = invoices_list[0].client_contract_number.client_number.name invoice_gross = invoices_list[0].invoice_gross payment_date = invoices_list[0].payment_date if payment_date <= datetime.now(): owing = invoice_gross if payment_date > datetime.now(): owing = 0 else: owing= 0 return render_to_response(('index.html', locals()), {'invoices_list': invoices_list ,'invoice_number':invoice_number, 'invoice_name':invoice_name, 'invoice_gross':invoice_gross, 'payment_date':payment_date, 'owing': owing}, context_instance=RequestContext(request)) EDIT: Here is my template. The thing is the function owing is not in my models so saying {{invoices.owing}} wont work. {% for invoices in invoices_list %} <tr> <td>{{invoices.invoice_number}}</td> <td>{{invoices.invoice_contact}}</td> <td>{{invoices.client_contract_number}}</td> <td>{{invoices.payment_date|date:"d M Y"}}</td> <td>{{invoices.invoice_gross}}</td> <td>{{owing}}</td> {% endfor %}

    Read the article

  • Node.js/Express Partials problem: Can't be nested too deep?

    - by heorling
    I'm learning Node.js, Express, haml.js and liking it. I've run into a prety annoying problem though. I'm pretty new to this but have been getting nice results so far. I'm writing a jquery heavy web app that relies on a table containing divs. The divs slide around, switch back and fourth and are resized etc to my hearts content. What I'm looking for a way to switch (template?) the divs. Since I've been building in express and mimicking the chat example it would make sense to use partials. The rub is that I've been using inexplicit divs in haml, held within a td. The divs are cunstructed as follows: %tr %td .class1.class2.class3.classetc Which has worked fine cross browser. Parsing the classes works great for the js code to pass arguments around, fetch values etc. What I'd like to be able to do is something like: %tr %td .class1.class2.class3.classetc %ul#messages != this.partial('message.html.haml', { collection: messages }) Any combination I've tried with this has failed however. And I might have tried them all. If I could put a partial into that div I'd probably be set. And you can nest them as long as you use #ids instead of .classes. But if you use more than one class it breaks! I think that's the most accurate way of summing it up. How do you do this? I've checked out various templating solutions like mu.js and micro template like by John Resig. I earlier checked out this thread on templating engines. It's very possible I'm making some fundamental mistake here, I'm new to this. What's a good way to do this?

    Read the article

  • Obtain the pathName dynamically for ASP.NET MVC

    - by vikitor
    Hello, I'm looking for a solution that allows me to get the parent page pathname from a partialView invoked. For example I have an Action baa and a controller boo so the javascript to obtain this will be window.location.pathname, and it returns /boo/baa. The thing is that I use a partial view, so when I try to retrieve the pathname via the URL helper, what I obtain is the PartialView one, and what I need is the pathname for the action that invokes it. I want to do this because I want to show certain things of the partial view depending on the pathname of the parent view that invokes it. Is there a way to do this with ASP.NET MVC? Thank you all in advance,

    Read the article

  • HttpResponseRedirect question

    - by Hulk
    Cant we send a dictionary variable when using HttpResponseRedirect render_to_response('edited/display.html',context_instance=RequestContext(request,{'newlist': newlist})) //How can the dictionary and the request sent back again //sumthing like this return HttpResponseRedirect('edited/display.html',context_instance=RequestContext(request,{'newlist': newlist}))

    Read the article

  • View changes nvarchars to varchars in SQL Server 2008

    - by Traples
    I have a view in a SQL Server 2008 db that simply exposes about 20 fields of one table to be consumed via ODBC to a client. When I tried to replicate this view in another database, the client could not consume the data source. Then I noticed some weirdness. The columns in the view are shown, in SQL Server Management Studio, to be varchar(100), while the columns in the table are defined as nvarchar(100). There are no CAST or CONVERT statements in the view, it is a simple SELECT statement. Example: Table - Columns: Desc1 (nvarchar(100), null) View - SELECT TOP 100 PERCENT Desc1 FROM... Columns: Desc1 (varchar(100), null) Any ideas why the columns are defined as varchar in the view instead of nvarchar?

    Read the article

  • Best way to write an image to a Django HttpResponse()

    - by k-g-f
    I need to serve images securely to validated users only (i.e. they can't be served as static files). I currently have the following Python view in my Django project, but it seems inefficient. Any ideas for a better way? def secureImage(request,imagePath): response = HttpResponse(mimetype="image/png") img = Image.open(imagePath) img.save(response,'png') return response (Image is imported from PIL.)

    Read the article

  • Is there a way to get direct_to_template to pass RequestContext in django?

    - by BigJason
    I have found myself writing the same view over and over. It is basically this: def home_index(request): return render_to_response('home/index.html', RequestContext(request)) To keep with the dry principal, I would like to utilize a generic view. I have seen direct_to_template, but it passes an empty context. So how can I use a generic view and still get the power of RequestContext?

    Read the article

  • How to make my view better to save Django

    - by user558251
    Hy guys sorry for this post but i need help with my application, i need optimize my view. I have 5 models, how i can do this? def save(request): # get the request.POST in content if request.POST: content = request.POST dicionario = {} # create a dict to get the values in content for key,value in content.items(): # get my fk Course.objects if key == 'curso' : busca_curso = Curso.objects.get(id=value) dicionario.update({key:busca_curso}) else: dicionario.update({key:value}) #create the new teacher Professor.objects.create(**dicionario) my questions are? 1 - How i can do this function in a generic way? Can I pass a variable in a %s to create and get? like this way ? foo = "Teacher" , bar = "Course" def save(request, bar, foo): if request post: ... if key == 'course' : get_course = (%s.objects.get=id=value) %bar ... (%s.objects.create(**dict)) %foo ??? i tried do this in my view but don't work =/, can somebody help me to make this work ? Thanks

    Read the article

  • Local variable not being passed to partial template by render?

    - by brad
    I don't seem to be able to pass a variable to my partial template in rails (2.3.5). My code is as follows; In the main view .html.erb file: <% f.fields_for :payments do |payment_form| %> <%= render 'payment', {:f => payment_form, :t => "test" } %> <% end %> and in the _payment.html.erb file: <%= t %> produces a wrong number of arguments (0 for 1) error. The payment_form object is being passed to the partial as f without any problems. I've tried a number of variations on the above syntax (e.g. :locals => {:f => payment_form, :t => "test" } without success. I presume I'm doing something pretty basic wrong but just can't see it.

    Read the article

  • Emulating Preference look/feel with LinearLayout

    - by colinodell
    I really like the look and feel of the Preference UI items and want to replicate that in my application. Basically I've got an Activity with a couple LinearLayouts set to be focusable. When they are focused, I want them to turn green (like Preferences do). Any idea how to apply that style to my LinearLayouts? Note: The LinearLayouts are essentially going to be clickable 'buttons' to launch a separate activity. They are NOT actual preferences or buttons, although they need to look/act similar to them.)

    Read the article

  • Ruby on Rails AJAX call affects only the first element in collection

    - by pruett
    I'm iterating over a collection of elements and trying to get AJAX to work properly on a specific element within the collection. I'm nesting a few partials in order to iterate over these items and use a js.erb call like this: $('#favorite_form').html("<%=j render partial: 'shared/unfavorite', locals: { mission: @mission } %>"); This only seems to change the 1st item in the collection even though I could be clicking the 5th item down the list, for example. Question: How can I specify (via .js and AJAX) which element to update? Is this jQuery call not specific enough to the individual element? The code works in regular HTTP requests, so I'm wondering if there is a way to specify the individual element, but I thought that's what partials did :/ Example View ( _favorites.html.erb ) <div id="favorite_form"> <% if you_favorited_this?(current_user, mission) %> <%= render partial: 'shared/unfavorite', locals: { mission: mission } %> <% else %> <%= render partial: 'shared/favorite', locals: { mission: mission } %> <% end %> </div>

    Read the article

  • Django - Add rows to MySQL database

    - by yeenow123
    So I already have a database setup with a few columns and a few rows already inserted in. I'm trying to create a view that you would just input information into a form and press Submit, then a row would be added to the MySQL database with the information you just typed in. I believe you can do this with admin, but I would like to try without admin and I'm not sure if this is possible? I've been using the MySQL commandline to add rows as of now..

    Read the article

  • Rails view - user enters minutes, we save seconds?

    - by sscirrus
    Hi everyone, I have a simple text_field in my form where a user enters a time in minutes, i.e. 60. How can I multiply that number by 60 before saving the form, such that the database stores the number in seconds? Then, how do I reverse that and show the field in minutes on another view? Thank you!

    Read the article

< Previous Page | 69 70 71 72 73 74 75 76 77 78 79 80  | Next Page >