Search Results

Search found 13135 results on 526 pages for 'actor model'.

Page 105/526 | < Previous Page | 101 102 103 104 105 106 107 108 109 110 111 112  | Next Page >

  • Django IN query as a string result - invalid literal for int() with base 10

    - by bmelton
    Trying to query a 'Favorites' model to get a list of items a user has favorited, and then querying against a different model to get the objects back from that query to present to the template, but I'm getting an error: "invalid literal for int() with base 10" Looking over all of the other instances of that error, I couldn't find any in which the asker actually wanted to work with a comma separated list of integers, so I'm kind of at a loss. Model class Favorite(models.Model): # key should be the model name, id is the model.id, and user is the User object. key = models.CharField(max_length=255, unique=True) val = models.IntegerField(default=0) user = models.ForeignKey(User) class Admin: list_display = ('key', 'id', 'user') View def index(request): favorites = Favorite.objects.filter(key='blog', user=request.user.pk) values = "" for favorite in favorites: values += "%s," % favorite.val #values = "[%s]" % values blogs = Blog.objects.filter(pk__in=values) return render_to_response('favorite/index.html', { "favorites" : favorites, "blogs" : blogs, "values" : values, }, context_instance=RequestContext(request) ) enter code here

    Read the article

  • populate a comboBox in Griffon App dynamically

    - by kulkarni
    I have 2 comboBoxes in my View of Griffon App (or groovy swingBuilder) country = comboBox(items:country(), selectedItem: bind(target:model, 'country', value:model.country), actionPerformed: controller.getStates) state = comboBox(items:bind(source:model, sourceProperty:'states'), selectedItem: bind(target:model, 'state', value:model.state)) The getStates() in the controller, populates @Bindable List states = [] in the model based on the country selected. The above code doesn't give any errors, but the states are never populated. I changed the states from being List to a range object(dummy), it gives me an error MissingPropertyException No such property items for class java.swing.JComboBox. Am I missing something here? There are a couple of entries related to this on Nabble but nothing is clear. The above code works if I had a label instead of a second comboBox.

    Read the article

  • Django models: Use multiple values as a key?

    - by Rosarch
    Here is a simple model: class TakingCourse(models.Model): course = models.ForeignKey(Course) term = models.ForeignKey(Term) Instead of Django creating a default primary key, I would like to use both course and term as the primary key - taken together, they uniquely identify a tuple. Is this allowed by Django? On a related note: I am trying to represent users taking courses in certain terms. Is there a better way to do this? class Course(models.Model): name = models.CharField(max_length=200) requiredFor = models.ManyToManyField(RequirementSubSet, blank=True) offeringSchool = models.ForeignKey(School) def __unicode__(self): return "%s at %s" % (self.name, self.offeringSchool) class MyUser(models.Model): user = models.ForeignKey(User, unique=True) takingReqSets = models.ManyToManyField(RequirementSet, blank=True) takingTerms = models.ManyToManyField(Term, blank=True) takingCourses = models.ManyToManyField(TakingCourse, blank=True) school = models.ForeignKey(School) class TakingCourse(models.Model): course = models.ForeignKey(Course) term = models.ForeignKey(Term) class Term(models.Model): school = models.ForeignKey(School) isPrimaryTerm = models.BooleanField()

    Read the article

  • Why do I get a AssociationTypeMismatch when creating my model object?

    - by Maxm007
    Hi I get the following error: ActiveRecord::AssociationTypeMismatch in ContractsController#create ExchangeRate(#2183081860) expected, got HashWithIndifferentAccess(#2159586480) Params: {"commit"=>"Create", "authenticity_token"=>"g2/Vm2pTcDGk6uRas+aTgpiQiGDY8lsc3UoL8iE+7+E=", "contract"=>{"side"=>"BUY", "currency_id"=>"488525179", "amount"=>"1000", "user_id"=>"633107804", "exchange_rate"=>{"rate"=>"1.7"}}} My relevant model is : class Contract < ActiveRecord::Base belongs_to :currency belongs_to :user has_one :exchange_rate has_many :trades accepts_nested_attributes_for :exchange_rate end class ExchangeRate < ActiveRecord::Base belongs_to :denccy, :class_name=>"Currency" belongs_to :numccy, :class_name=>"Currency" belongs_to :contract end My view is: <% form_for @contract do |contractForm| %> Username: <%= contractForm.collection_select(:user_id, User.all, :id, :username) %> <br> B/S: <%= contractForm.select(:side,options_for_select([['BUY', 'BUY'], ['SELL', 'SELL']], 'BUY')) %> <br> Currency: <%= contractForm.collection_select(:currency_id, Currency.all, :id, :ccy) %> <br> <br> Amount: <%= contractForm.text_field :amount %> <br> <% contractForm.fields_for @contract.exchange_rate do |rateForm|%> Rate: <%= rateForm.text_field :rate %> <br> <% end %> <%= submit_tag :Create %> <% end %> My View Controller: class ContractsController < ApplicationController def new @contract = Contract.new @contract.build_exchange_rate respond_to do |format| format.html # new.html.erb format.xml { render :xml => @contract } end end def create @contract = Contract.new(params[:contract]) respond_to do |format| if @contract.save flash[:notice] = 'Contract was successfully created.' format.html { redirect_to(@contract) } format.xml { render :xml => @contract, :status => :created, :location => @contract } else format.html { render :action => "new" } format.xml { render :xml => @contract.errors, :status => :unprocessable_entity } end end end I'm not sure why it's not recognizing the exchange rate attributes? Thank you

    Read the article

  • ASP.NET MVC: Accessing ModelMetadata for items in a collection

    - by DanM
    I'm trying to write an auto-scaffolder for Index views. I'd like to be able to pass in a collection of models or view-models (e.g., IEnumerable<MyViewModel>) and get back an HTML table that uses the DisplayName attribute for the headings (th elements) and Html.Display(propertyName) for the cells (td elements). Each row should correspond to one item in the collection. When I'm only displaying a single record, as in a Details view, I use ViewData.ModelMetadata.Properties to obtain the list of properties for a given model. But what happens when the model I pass to the view is a collection of model or view-model objects and not a model or view-model itself? How do I obtain the ModelMetadata for a particular item in a collection?

    Read the article

  • rails named_scope ignores eager loading

    - by Craig
    Two models (Rails 2.3.8): User; username & disabled properties; User has_one :profile Profile; full_name & hidden properties I am trying to create a named_scope that eliminate the disabled=1 and hidden=1 User-Profiles. The User model is usually used in conjunction with the Profile model, so I attempt to eager-load the Profile model (:include = :profile). I created a named_scope on the User model called 'visible': named_scope :visible, { :joins => "INNER JOIN profiles ON users.id=profiles.user_id", :conditions => ["users.disabled = ? AND profiles.hidden = ?", false, false] } I've noticed that when I use the named_scope in a query, the eager-loading instruction is ignored. Variation 1 - User model only: # UserController @users = User.find(:all) # User's Index view <% for user in @users %> <p><%= user.username %></p> <% end %> # generates a single query: SELECT * FROM `users` Variation 2 - use Profile model in view; lazy load Profile model # UserController @users = User.find(:all) # User's Index view <% for user in @users %> <p><%= user.username %></p> <p><%= user.profile.full_name %></p> <% end %> # generates multiple queries: SELECT * FROM `profiles` WHERE (`profiles`.user_id = 1) ORDER BY full_name ASC LIMIT 1 SHOW FIELDS FROM `profiles` SELECT * FROM `profiles` WHERE (`profiles`.user_id = 2) ORDER BY full_name ASC LIMIT 1 SELECT * FROM `profiles` WHERE (`profiles`.user_id = 3) ORDER BY full_name ASC LIMIT 1 SELECT * FROM `profiles` WHERE (`profiles`.user_id = 4) ORDER BY full_name ASC LIMIT 1 SELECT * FROM `profiles` WHERE (`profiles`.user_id = 5) ORDER BY full_name ASC LIMIT 1 SELECT * FROM `profiles` WHERE (`profiles`.user_id = 6) ORDER BY full_name ASC LIMIT 1 Variation 3 - eager load Profile model # UserController @users = User.find(:all, :include => :profile) #view; no changes # two queries SELECT * FROM `users` SELECT `profiles`.* FROM `profiles` WHERE (`profiles`.user_id IN (1,2,3,4,5,6)) Variation 4 - use name_scope, including eager-loading instruction #UserConroller @users = User.visible(:include => :profile) #view; no changes # generates multiple queries SELECT `users`.* FROM `users` INNER JOIN profiles ON users.id=profiles.user_id WHERE (users.disabled = 0 AND profiles.hidden = 0) SELECT * FROM `profiles` WHERE (`profiles`.user_id = 1) ORDER BY full_name ASC LIMIT 1 SELECT * FROM `profiles` WHERE (`profiles`.user_id = 2) ORDER BY full_name ASC LIMIT 1 SELECT * FROM `profiles` WHERE (`profiles`.user_id = 3) ORDER BY full_name ASC LIMIT 1 SELECT * FROM `profiles` WHERE (`profiles`.user_id = 4) ORDER BY full_name ASC LIMIT 1 Variation 4 does return the correct number of records, but also appears to be ignoring the eager-loading instruction. Is this an issue with cross-model named scopes? Perhaps I'm not using it correctly. Is this sort of situation handled better by Rails 3?

    Read the article

  • how do you reuse a partial view with different ids

    - by oo
    i have a partial view with a dropdown in it. the code looks like this: <%=Html.DropDownListFor(x => Model.Exercises, new SelectList(Model.Exercises, "Id", "Name", Model.SelectedExercise), new { @id = "exerciseDropdown", @class = "autoComplete" })%> the issue is that i want to reuse this partial view in multiple places but i want to have a different id assigned to the control (instead of exerciseDropdown always) but on the outside i only have this . . <% Html.RenderPartial("ExerciseList", Model); %> is there anyway to pass in an id into a partial view. should i stick this into my view model as a seperate property "Model.ExerciseDropdown2" for example. is there a better way ?

    Read the article

  • ASP.NET MVC Page - Viewstate for Confirm email field is getting erased on Registration Page if valid

    - by Rita
    Hi I have a Registaration page with the following fields Email, Confirm Email, Password and Confrim Password. On Register Button click and post the model to the server, the Model validates and if that Email is already Registered, it displays the Validation Error Message "User already Exists. Please Login or Register with a different email ID". While we are displaying this validation error message, I am loosing the value of "Confirm Email" field. So that the user has to reenter again and I want to avoid this. Here I don't have confirm_Email field in my Model. Is there something special that has to be done to remain Confirm Email value on the Page even in case of Validation failure? Appreciate your responses. Here is my Code: <% using (Html.BeginForm()) {%> <%= Html.ValidationSummary(false) %> <fieldset> <div class="cssform"> <p> <%= Html.LabelFor(model => model.Email)%><em>*</em> <%= Html.TextBoxFor(model => model.Email, new { @class = "required email" })%> <%= Html.ValidationMessageFor(model => model.Email)%> </p> <p> <%= Html.Label("Confirm email")%><em>*</em> <%= Html.TextBox("confirm_email")%> <%= Html.ValidationMessage("confirm_email") %> </p> <p> <%= Html.Label("Password")%><em>*</em> <%= Html.Password("Password", null, new { @class = "required" })%> <%= Html.ValidationMessage("Password")%><br /> (Note: Password should be minimum 6 characters) </p> <p> <%= Html.Label("Confirm Password")%><em>*</em> <%= Html.Password("confirm_password")%> <%= Html.ValidationMessage("confirm_password") %> </p><hr /> <p>Note: Confirmation email will be sent to the email address listed above.</p> </fieldset> <% } %>

    Read the article

  • how do you reuse a partial view with setting different ids

    - by oo
    i have a partial view with a dropdown in it. the code looks like this: <%=Html.DropDownListFor(x => Model.Exercises, new SelectList(Model.Exercises, "Id", "Name", Model.SelectedExercise), new { @id = "exerciseDropdown", @class = "autoComplete" })%> the issue is that i want to reuse this partial view in multiple places but i want to have a different id assigned to the control (instead of exerciseDropdown always) but on the outside i only have this . . <% Html.RenderPartial("ExerciseList", Model); %> is there anyway to pass in an id into a partial view. is there a standard way to inject the ids into a partial view ? right now i am doing things like this: <% Html.RenderPartial("ExerciseList", Model); %> <% Html.RenderPartial("ExerciseList2", Model); %> where ExerciseList and ExerciseList2 are identical but with different ids but i am sure there is a better way.

    Read the article

  • Testing subpackage modules in Python 3

    - by Mitchell Model
    I have been experimenting with various uses of hierarchies like this and the differences between absolute and relative imports, and can't figure out how to do routine things with the package, subpackages, and modules without simply putting everything on sys.path. I have a two-level package hierarchy: MyApp __init__.py Application __init__.py Module1 Module2 ... Domain __init__.py Module1 Module2 ... UI __init__.py Module1 Module2 ... I want to be able to do the following: Run test code in a Module's "if main" when the module imports from other modules in the same directory. Have one or more test code modules in each subpackage that runs unit tests on the modules in the subpackage. Have a set of unit tests that reside in someplace reasonable, but outside the subpackages, either in a sibling package, at the top-level package, or outside the top-level package (though all these might end up doing is running the tests in each subpackage) "Enter" the structure from any of the three subpackage levels, e.g. run code that just uses Domain modules, run code that just uses Application modules, but Application uses code from both Application and Domain modules, and run code from GUI uses code from both GUI and Application; for instance, Application test code would import Application modules but not Domain modules. After developing the bulk of the code without subpackages, continue developing and testing after organizing the modules into this hierarchy. I know how to use relative imports so that external code that puts MyApp on its sys.path can import MyApp, import any subpackages it wants, and import things from their modules, while the modules in each subpackage can import other modules from the same subpackage or from sibling packages. However, the development needs listed above seem incompatible with subpackage structuring -- in other words, I can't have it both ways: a well-structured multi-level package hierarchy used from the outside and also used from within, in particular for testing but also because modules from one design level (in particular the UI) should not import modules from a design level below the next one down. Sorry for the long essay, but I think it fairly represents the struggles a lot of people have been having adopting to the new relative import mechanisms.

    Read the article

  • Problem with Models on Master Page View.

    - by user342514
    Have a problem with master page views and models. In the first image, I have a simple view in which I am trying to access the Model properties. None of the model properties are available at this time (this is the problem). If I use a <%= Model.blah % then you can see that the model properties are available. Second photo. In the last photo you will now see that I can access the Model properties that I was trying to access in the first photo. An error will be thrown if viewing this page if you don't first do <%= with the model. CS1061: 'object' does not contain a definition for 'User' and no extension method 'User' accepting a first argument of type 'object' could be found (are you missing a using directive or an assembly reference?) http://yfrog.com/8b43656447p So why is this happening?

    Read the article

  • [Django] Change state of obiects

    - by gameboy
    hi I have following problem. I have model: class Towar(models.Model): nrSeryjny=models.CharField(max_length=100) opis=models.CharField(max_length=255) naStanie=models.NullBooleanField(null=True) def __unicode__(self): return "%s" % self.opis def lowerName(self): return self.__class__.__name__.lower() def checkState(self): return self.naStanie def changeState(self,state): self.naStanie=state class Meta: ordering=['nrSeryjny'] app_label = 'baza' permissions=(("view_towar","mozna miec podglad dla towar"),) and model : class Wypozyczenie(models.Model): dataPobrania=models.DateField() pracownik=models.ForeignKey(User,null=True) kontrahent=models.ForeignKey(Kontrahenci,null=True) towar=models.ForeignKey(Towar,null=True) objects=WypozyczenieManager() default_objects=models.Manager() ZwrotyObjects=WypozyczenieZwrotyManager() def lowerName(self): return self.__class__.__name__.lower() def __unicode__(self): if self.towar == None: return "Dla:%s -- Kto:%s -- Kiedy:%s -- Co:%s" % (self.kontrahent,self.pracownik,self.dataPobrania,"Brak") else: return "Dla:%s -- Kto:%s -- Kiedy:%s -- Co:%s" % (self.kontrahent,self.pracownik,self.dataPobrania,self.towar) class Meta: ordering=['dataPobrania'] app_label = 'baza' permissions=(("view_wypozyczenie","mozna miec podglad dla wypozyczenie"),) and view to adding models: def modelAdd(request,model,modelForm): mod=model() if request.user.has_perm('baza.add_%s' % mod.lowerName()): if request.method=='POST': form=modelForm(request.POST) if form.is_valid(): form.save() return HttpResponseRedirect('/'+ mod.lowerName() + '/') else: form=modelForm() v=RequestContext(request,{'form':form}) return render_to_response('add_form.html',v) and i whant do that, when i add Wypozyczenie and save it then the Towar that is stored by Wypozyczenie change his na stanie from True to False Greets

    Read the article

  • MVC paths in Extjs

    - by Oleg
    I have got a ExtJs application (MVC). So, I define many controllers, models, views and stores. At now, the structure of my project is not easy. For example my model: Ext.define('KP.model.account.AccountList', { extend: 'Ext.data.Model', fields: ['parameter', 'string_value'] }); I define my store with model like this: Ext.define('KP.store.account.AccountList', { extend: 'Ext.data.Store', alias: 'store.s_AccountList', model: 'KP.model.account.AccountList', ...................................... }); If I want to move some .js files, I must rewrite many paths in classes definitions. So, how can I declare my classes (by alias maybe) and use them more effectively? It's need, If I move files on files tree. Thanks!

    Read the article

  • Carscading dropdowns

    - by SnowJim
    Hi! I am working with carscading dropdowns in MVC. It apears that I will not be able to easaly create dropdowns on demand, instead I will have to add the dropdowns before sending it to the client. This is how are doing it right now : In the aspx page <%: Html.DropDownListFor(model => model.ModelViewAd.Category1, Model.ModelViewAd.Category1List, "-- Välj kategori --")%> <%: Html.DropDownListFor(model => model.ModelViewAd.Category2, Model.ModelViewAd.Category2List, "-- Välj kategori --")%> <%: Html.DropDownListFor(model => model.ModelViewAd.Category3, Model.ModelViewAd.Category3List, "-- Välj kategori --")%> <%: Html.DropDownListFor(model => model.ModelViewAd.Category4, Model.ModelViewAd.Category4List, "-- Välj kategori --")%> This is rendered like this : <select id="ModelViewAd_Category1" name="ModelViewAd.Category1"> <option value="">-- V&#228;lj kategori --</option> <option value="10">Fordon</option> <option value="15">F&#246;r hemmet</option> <option value="17">Bostad</option> </select> <select id="ModelViewAd_Category2" name="ModelViewAd.Category2"> <option value="">-- V&#228;lj kategori --</option> </select> <select id="ModelViewAd_Category3" name="ModelViewAd.Category3"> <option value="">-- V&#228;lj kategori --</option> </select> <select id="ModelViewAd_Category4" name="ModelViewAd.Category4"> <option value="">-- V&#228;lj kategori --</option> </select> This is how the script on the page looks like : <script type="text/javascript"> $(function () { $("select#ModelViewAd_Category1").change(function () { var id = $(this).val(); var urlAction = "/AdCategory/GetCategoriesByParent1/" + id; $.getJSON(urlAction, { id: id }, function (data) { $("#ModelViewAd_Category2").addItems(data.d); }); }); $("select#ModelViewAd_Category2").change(function () { var id = $(this).val(); var urlAction = "/AdCategory/GetCategoriesByParent1/" + id; $.getJSON(urlAction, { id: id }, function (data) { $("#ModelViewAd_Category3").addItems(data.d); }); }); $("select#ModelViewAd_Category3").change(function () { var id = $(this).val(); var urlAction = "/AdCategory/GetCategoriesByParent1/" + id; $.getJSON(urlAction, { id: id }, function (data) { $("#ModelViewAd_Category4").addItems(data.d); }); }); }); </script> And then I have a included file that contains this : $.fn.clearSelect = function () { return this.each(function () { if (this.tagName == 'SELECT') this.options.length = 0; }); } $.fn.addItems = function (data) { return this.clearSelect().each(function () { if (this.tagName == 'SELECT') { var dropdownList = this; $.each(data, function (index, optionData) { var option = new Option(optionData.Text, optionData.Value); if ($.browser.msie) { dropdownList.add(option); } else { dropdownList.add(option, null); } if ($(this).children().size() < 2) { $(this).hide(); } else { $(this).show(); } }); } }); } The problem I now have is that I need to hide the dropdowns that do not contain any options or do only contains one option. This should be checked when doing a call to the service as well as when the page is sent to the client ("POSTBACK"). What I need is : 4 Dropdowns Only the first dropdown is visible when first entering the page. When selecting a option from dropdown1 the dropdown2 will be populated and so on If there is only 1 option then the dropdown should be hidden If all 4 dropdowns is set and the end-user change dropdown 1, then dropdown2 should be reloaded and the rest be hidden If the user have selected some of the dropdowns(say 1,2 and 3) and hit submit and the page is not accepted on the server side(not valid) the dropdowns should be set exacly as when the user cliked the submit button when the page returns to the user. Any suggestions on this?

    Read the article

  • how to use html.befinform..in usercontroler

    - by kumar
    <% using (Html.BeginForm("edit", "StudentDetails", FormMethod.Post, new { @id="exc-" + Model.StudentID})) {% <%= Html.ValidationSummary(true)% based on the condition like <%if(model.Summary == "1")%> I need to go to StudnetDetails Controler to execute Edit if not Need to go Details Controler to Edit some info.. and I have button in the page like save.. <p> <%=Html.EditorFor(model => model.SequenceDateTimeAsString)%> <%=Html.EditorFor(model => model.ID)%> <input type="submit" class="button" value="Save" /> </p> Can any body help me out how to handle how actions on condition thanks

    Read the article

  • What are the steps to convert this function to a model/controller in Zend Framework?

    - by Joel
    Hi guys, I'm learning Zend Framework MVC, and I have a website that is mainly static php pages. However one of the pages is using functions, etc, and I'm trying to figure out what the process is for converting this to an OOP setup. Within the <body> I have this function (and more, but this is the first function): function filterEventDetails($contentText) { $data = array(); foreach($contentText as $row) { if(strstr($row, 'When: ')) { ##cleaning "when" string to get date in the format "May 28, 2009"## $data['duration'] = str_replace('When: ','',$row); list($when, ) = explode(' to ',$data['duration']); $data['when'] = substr($when,4); if(strlen($data['when'])>13) $data['when'] = trim(str_replace(strrchr($data['when'], ' '),'',$data['when'])); $data['duration'] = substr($data['duration'], 0, strlen($data['duration'])-4); //trimming time zone identifier (UTC etc.) } if(strstr($row, 'Where: ')) { $data['where'] = str_replace('Where: ','',$row); //pr($row); //$where = strstr($row, 'Where: '); //pr($where); } if(strstr($row, 'Event Description: ')) { $event_desc = str_replace('Event Description: ','',$row); //$event_desc = strstr($row, 'Event Description: '); ## Filtering event description and extracting venue, ticket urls etc from it. //$event_desc = str_replace('Event Description: ','',$contentText[3]); $event_desc_array = explode('|',$event_desc); array_walk($event_desc_array,'get_desc_second_part'); //pr($event_desc_array); $data['venue_url'] = $event_desc_array[0]; $data['details'] = $event_desc_array[1]; $data['tickets_url'] = $event_desc_array[2]; $data['tickets_button'] = $event_desc_array[3]; $data['facebook_url'] = $event_desc_array[4]; $data['facebook_icon'] = $event_desc_array[5]; } } return $data; } ?> So right now I have this in my example.phtml view page. I understand this needs to be a model and acted on by the controller, but I'm really not sure where to start with this conversion? This is a function tht is taking info from a Google calendar and parsing it for the view. Thanks for any help!

    Read the article

  • How to call a jquery function from an action method in controller?

    - by Hasan Fahim
    I have a requirement to open a popup from an action method in controller. The action method is basically registering a user. [HttpPost] public ActionResult Register(RegisterModel model) { if (ModelState.IsValid) { MembershipCreateStatus createStatus; Membership.CreateUser(model.UserName, model.Password, model.Email, null, null, true, null, out createStatus); if (createStatus == MembershipCreateStatus.Success) { FormsAuthentication.SetAuthCookie(model.UserName, false /* createPersistentCookie */); //------------------------------------------ //I need to call a jquery function from here //------------------------------------------ return RedirectToAction("Index", "Home"); } else { ModelState.AddModelError("", ErrorCodeToString(createStatus)); } } return View(model); } The jquery function, present in the view, would just make a hidden DIV, visible, and set the opacity, etc, to represent a popup. I need to call such a jquery function from the controller's action method shown above.

    Read the article

  • manage date fields when are int in the db

    - by Luca Romagnoli
    Hi in my db there is a field "date_start" type integer. This is the part of form for this field <div class="editor-label"> <%: Html.LabelFor(model => model.date_start) %> </div> <div class="editor-field"> <%: Html.TextBoxFor(model => model.date_start, new { @class = "calendar" })%> <%: Html.ValidationMessageFor(model => model.date_start) %> </div> In the form i want that the field's format is date type. and memorize it in int type after calling a my function for the convertion. How can i manage it? thanks

    Read the article

  • Rails object inheritence with belongs_to

    - by Rabbott
    I have a simple has_many/belongs_to relationship between Report and Chart. The issue I'm having is that my Chart model is a parent that has children. So in my Report model I have class Report < ActiveRecord::Base has_many :charts end And my Chart model is a parent, where Pie, Line, Bar all inherit from Chart. I'm not sure where the belongs_to :report belongs within the chart model, or children of chart model. I get errors when I attempt to access chart.report because the object is of type "Class" undefined local variable or method `report' for #< Class:0x104974b90 The Chart model uses STI so its pulling say.. 'Pie' from the chart_type column in the charts table.. what am I missing?

    Read the article

  • Cascading dropdowns

    - by SnowJim
    Hi! I am working with cascading dropdowns in MVC. It appears that I will not be able to easily create dropdowns on demand, instead I will have to add the dropdowns before sending it to the client. This is how I am doing it right now: In the aspx page <%: Html.DropDownListFor(model => model.ModelViewAd.Category1, Model.ModelViewAd.Category1List, "-- Välj kategori --")%> <%: Html.DropDownListFor(model => model.ModelViewAd.Category2, Model.ModelViewAd.Category2List, "-- Välj kategori --")%> <%: Html.DropDownListFor(model => model.ModelViewAd.Category3, Model.ModelViewAd.Category3List, "-- Välj kategori --")%> <%: Html.DropDownListFor(model => model.ModelViewAd.Category4, Model.ModelViewAd.Category4List, "-- Välj kategori --")%> This is rendered like this : <select id="ModelViewAd_Category1" name="ModelViewAd.Category1"> <option value="">-- V&#228;lj kategori --</option> <option value="10">Fordon</option> <option value="15">F&#246;r hemmet</option> <option value="17">Bostad</option> </select> <select id="ModelViewAd_Category2" name="ModelViewAd.Category2"> <option value="">-- V&#228;lj kategori --</option> </select> <select id="ModelViewAd_Category3" name="ModelViewAd.Category3"> <option value="">-- V&#228;lj kategori --</option> </select> <select id="ModelViewAd_Category4" name="ModelViewAd.Category4"> <option value="">-- V&#228;lj kategori --</option> </select> This is what the script on the page looks like: <script type="text/javascript"> $(function () { $("select#ModelViewAd_Category1").change(function () { var id = $(this).val(); var urlAction = "/AdCategory/GetCategoriesByParent1/" + id; $.getJSON(urlAction, { id: id }, function (data) { $("#ModelViewAd_Category2").addItems(data.d); }); }); $("select#ModelViewAd_Category2").change(function () { var id = $(this).val(); var urlAction = "/AdCategory/GetCategoriesByParent1/" + id; $.getJSON(urlAction, { id: id }, function (data) { $("#ModelViewAd_Category3").addItems(data.d); }); }); $("select#ModelViewAd_Category3").change(function () { var id = $(this).val(); var urlAction = "/AdCategory/GetCategoriesByParent1/" + id; $.getJSON(urlAction, { id: id }, function (data) { $("#ModelViewAd_Category4").addItems(data.d); }); }); }); </script> And then I have an included file that contains this: $.fn.clearSelect = function () { return this.each(function () { if (this.tagName == 'SELECT') this.options.length = 0; }); } $.fn.addItems = function (data) { return this.clearSelect().each(function () { if (this.tagName == 'SELECT') { var dropdownList = this; $.each(data, function (index, optionData) { var option = new Option(optionData.Text, optionData.Value); if ($.browser.msie) { dropdownList.add(option); } else { dropdownList.add(option, null); } if ($(this).children().size() < 2) { $(this).hide(); } else { $(this).show(); } }); } }); } The problem I now have is that I need to hide the dropdowns that do not contain any options or only contain one option. This should be checked when doing a call to the service as well as when the page is sent to the client ("POSTBACK"). What I need is : 4 Dropdowns Only the first dropdown is visible when first entering the page. When selecting an option from dropdown1 the dropdown2 will be populated and so on If there is only 1 option then the dropdown should be hidden If all 4 dropdowns are set and the end-user changes dropdown1, then dropdown2 should be reloaded and the rest be hidden If the user has selected some of the dropdowns (say 1, 2 and 3) and hit submit and the page is not accepted on the server side (not valid) the dropdowns should be set exactly as when the user clicked the submit button when the page returns to the user. Any suggestions on this?

    Read the article

  • How to have the controller change its behavior depending on the view?

    - by Ian Boyd
    If from one view a user enters some invalid data, e.g.:     E-mail: [email protected]     then i want the controller to: not place the data into the model color the text box reddish not allow the user to save But it's possible that if the user enters the same invalid data in a different view i want the controller to: place the data into the model color the text box reddish allow the user to save But it's possible that if the user enters the same invalid data in a different view i want the controller to: place the data into the model color the text box bluish allow the user to save And it's possible that another view will: place the data into the model leave the text box uncolored allow the user to save And it's possible that another view will: auto-correct the data, placing it into the model color the text-box reddish allow the user to have And it's possible for another view to: auto-correct the data, placing it into the model update the view with the new data color the text-box bluish allow the user to save [ad infinitum] Without using n-controllers for n-views, how do i do this?

    Read the article

  • Class works without declaring variables?

    - by Maxim Droy
    I'm learned php as functional and procedure language. Right now try to start learn objective-oriented and got an important question. I have code: class car { function set_car($model) { $this->model = $model; } function check_model() { if($this->model == "Mercedes") echo "Good car"; } } $mycar = new car; $mycar->set_car("Mercedes"); echo $mycar->check_model(); Why it does work without declaration of $model? var $model; in the begin? Because in php works "auto-declaration" for any variables? I'm stuck

    Read the article

  • Creating tables with pylons and SQLAlchemy

    - by Sid
    I'm using SQLAlchemy and I can create tables that I have defined in /model/__init__.py but I have defined my classes, tables and their mappings in other files found in the /model directory. For example I have a profile class and a profile table which are defined and mapped in /model/profile.py To create the tables I run: paster setup-app development.ini But my problem is that the tables that I have defined in /model/__init__.py are created properly but the table definitions found in /model/profile.py are not created. How can I execute the table definitions found in the /model/profile.py so that all my tables can be created? Thanks for the help!

    Read the article

  • backbonejs remove anomaly concept

    - by user1537158
    I was building a small app for adding and deleting li from ul using Backbonejs.One of the SO members cymen helped me code it, using that i tailored the code a little.currently if i add one element and delete , it works , but the second time i add an element (to ul) and go to delete it , i get Uncaught TypeError: Cannot call method 'remove' of undefined Pasting my code here , HTML : <input type="text" id="name"> <button id="add">Add</button> <ul id="mylist"></ul> JS: $(function(){ var myCollection = Backbone.Collection.extend(); var myView = Backbone.View.extend({ el:$('body'), tagName:'li', initialize : function(e){ this.collection.bind("add",this.render,this); this.collection.bind("remove",this.render,this); }, events:{ 'click #add' : 'addfoo' }, addfoo : function(){ var myname= $('#name').val(); $('#name').val(''); this.collection.add({name:myname}); }, render : function(){ $('#mylist').empty(); this.collection.each(function(model){ console.log("myView"); var remove = new myRemoveView({model:model}); remove.render(); }); } }); var myRemoveView = Backbone.View.extend({ el:$('body'), events:{ 'click .button':'removeFoo' }, removeFoo : function(){ console.log("here"); this.model.collection.remove(this.model); }, render : function(){ console.log("second view"); $('#mylist').append('<li>'+this.model.get('name') + "<button class='button'>"+"delete"+"</button></li>"); return; } }); var view = new myView({collection: new myCollection()}); }); Two things i did not understand : i) in the removeFoo function , we write this.model.collection.remove(this.model) shouldnt this have been this.collection.model.remove , something of that sort ? ii) i add a li to ul , then i delete it , when i add another li (appending to ul works perfect) but this time when i go to delete it throws me the above error : Uncaught TypeError :cannot call method 'remove' of undefined can you please help me figure out these 2 doubts in my code , btw SO member cymen's code works like a charm only my tailored code (above) is giving me errors. SO member cymen's code : JS Fiddle for his code Thank you

    Read the article

< Previous Page | 101 102 103 104 105 106 107 108 109 110 111 112  | Next Page >