Search Results

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

Page 67/278 | < Previous Page | 63 64 65 66 67 68 69 70 71 72 73 74  | Next Page >

  • Keeping dates in order when using date_select and discarding year in Rails?

    - by MikeH
    My app has users who have seasonal products. When a user selects a product, we allow him to also select the product's season. We accomplish this by letting him select a start date and an end date for each product. We're using date_select to generate two sets of drop-downs: one for the start date and one for the end date. Including years doesn't make sense for our model. So we're using the option: discard_year => true To explain our problem, consider that our products are apples. Vendor X carries apples every year from September to January. Years are irrelevant here, and that's why we're using discard_year => true. However, while the specific years are irrelevant, the relative point in time from the start date to the end date is relevant. This is where our problem arises. When you use discard_year => true, Rails does set a year in the database, it just doesn't appear in the views. Rails sets all the years to 0001 in our app. Going back to our apple example, this means that the database now thinks the user has selected September 0001 to January 0001. This is a problem for us for a number of reasons. To solve this, the logic that I need to implement is the following: - If season_start month/date is before season_end month/date, then standard Rails approach is fine. - But, if season_start month/date is AFTER season_end month/date, then I need to dynamically update the database field such that the year for season_end is equal to the year for season_start + 1. My best guess is that I would create a custom method that runs as an after_save or after_update in my products model. But I'm not really sure how to do this. Ideas? Anybody ever had this issue? Thanks!

    Read the article

  • How to Inserting message into View that depends on session value. ASP.NET MVC. Best practice

    - by Andrew Florko
    User have to populate multistep questionnaire web-forms and step messages depend on the option chosen by user at the very beginning. Messages are stored in web.config file. I use asp.net mvc project, strong typed views and keep business logic separated from controller in static class. I don't want to make business logic dependency on web.config. Well, I have to insert message into view that depends on session value. There are at least 2 options how to implement this: View model has property that is populated in controller/businessLogic and rendered in view like <%: Model.HelpMessage1 %>. I have to pass web.config values from controller to businessLogic that makes business logic methods signature too complex. I don't want to make configuration source abstract (in order to let business logic read configuration values from its methods directly) also. Create static helper class that is called from view like <%: ViewHelper.HelpMessage1(Model.Option1) %>. But in this case logic what to show seems to be separated into two classes: business logic & viewHelper. What will you suggest? Thank you in advance!

    Read the article

  • return specific values from youtube

    - by user1631487
    I am trying to write a small function that will allow a user to submit a specific youtube channel url, and then return the number of views on the channel. Anyobne have any ideas? <!DOCTYPE html> <html> <head> </head> <body> <p id="demo">Click the button to get the value of the attribute with the specified namespaceURI and name</p> <button onclick="myFunction()">Try it</button> <script> function myFunction() { var http; if (window.XMLHttpRequest) {xhttp=new XMLHttpRequest();} else {xhttp=new ActiveXObject("Microsoft.XMLHTTP");} xhttp.open("GET","booksns.xml",false); xhttp.send(); var xmlDoc=xhttp.responseXML; var price=xmlDoc.getElementsByTagName("price")[0]; var x=document.getElementById("demo"); x.innerHTML=price.getAttributeNS("http://www.w3schools.com/NS","currency"); }; </script> </body> </html>

    Read the article

  • View Controller Question

    - by user341444
    First off I'm new at programming. I'm creating an app with one navigation bar controller. The app is pretty basic except for a quiz section that is comprised of 12 xibs. As the users takes the quiz a new xib is pushed onto the stack. I want to create a button that takes the user back to the home screen if they do not want to complete the quiz. The back button takes them to the previous xib which could be 11 deep. Is it possible to dismiss the modal views and reload the rootView controller? Here's the code from my delegate @synthesize window; @synthesize navigationController; (void)applicationDidFinishLaunching:(UIApplication *)application { // Override point for customization after application launch [window addSubview:[navigationController view]]; [window makeKeyAndVisible]; } (void)dealloc { [window release]; [navigationController release]; [super dealloc]; } This is how I'm pushing new xibs onto the stack (IBAction) showTesting: (id)sender { Testing *varTesting = [[[Testing alloc] initWithNibName:@"Testing" bundle:nil] autorelease]; [[self navigationController] pushViewController:varTesting animated: YES]; } Any help would be greatly appreciated. Thanks

    Read the article

  • Replacing text with variables

    - by Steve
    I have to send out letters to certain clients and I have a standard letter that I need to use. I want to replace some of the text inside the body of the message with variables. Here is my maturity_letter models.py class MaturityLetter(models.Model): default = models.BooleanField(default=False, blank=True) body = models.TextField(blank=True) footer = models.TextField(blank=True) Now the body has a value of this: Dear [primary-firstname], AN IMPORTANT REMINDER… You have a [product] that is maturing on [maturity_date] with [financial institution]. etc Now I would like to replace everything in brackets with my template variables. This is what I have in my views.py so far: context = {} if request.POST: start_form = MaturityLetterSetupForm(request.POST) if start_form.is_valid(): agent = request.session['agent'] start_date = start_form.cleaned_data['start_date'] end_date = start_form.cleaned_data['end_date'] investments = Investment.objects.all().filter(maturity_date__range=(start_date, end_date), plan__profile__agent=agent).order_by('maturity_date') inv_form = MaturityLetterInvestments(investments, request.POST) if inv_form.is_valid(): sel_inv = inv_form.cleaned_data['investments'] context['sel_inv'] = sel_inv maturity_letter = MaturityLetter.objects.get(id=1) context['mat_letter'] = maturity_letter context['inv_form'] = inv_form context['agent'] = agent context['show_report'] = True Now if I loop through the sel_inv I get access to sel_inv.maturity_date, etc but I am lost in how to replace the text. On my template, all I have so far is: {% if show_letter %} {{ mat_letter.body }} <br/> {{ mat_letter.footer }} {% endif %} Much appreciated.

    Read the article

  • MVVM Binding Orthogonal Aspects in Views e.g. Application Settings

    - by chibacity
    I have an application which I am developing using WPF\Prism\MVVM. All is going well and I have some pleasing MVVM implementations. However, in some of my views I would like to be able to bind application settings e.g. when a user reloads an application, the checkbox for auto-scrolling a grid should be checked in the state it was last time the user used the application. My view needs to bind to something that holds the "auto-scroll" setting state. I could put this on the view-model, but applications settings are orthogonal to the purpose of the view-model. The "auto-scroll" setting is controlling an aspect of the view. This setting is just an example. There will be quite a number of them and splattering my view-models with properties to represent application settings (so I can bind them) feels decidedly yucky. One view-model per view seems to be de rigeuer... What is best\usual practice here? Splatter my view-models with application settings? Have multiple view-models per view so settings can be represented in their own right? Split views so that controls can bind to an ApplicationSettingsViewModel? = too many views? Something else? Edit 1 To add a little more context, I am developing a UI with a tabbed interface. Each tab will host a single widget and there a variety of widgets. Each widget is a Prism composition of individual views. Some views are common amongst widgets e.g. a file picker view. Whilst each widget is composed of several views, as a whole, conceptually a widget has a single set of user settings e.g. last file selected, auto-scroll enabled, etc. These need to be persisted and retrieved\applied when the application starts again, and the widget views are created. My question is focused on the fact that conceptually a widget has a single set of user settings which is at right-angles to the fact that a widget consists of many views. Each view in the widget has it's own view-model (which works nicely and logically) but if I stick to a one view-model per view, I would have to splatter each view-model with user settings appropriate to it. This doesn't sound right ?!?

    Read the article

  • How can I create blog post functionality without Wordpress or Drupal?

    - by Ali
    I'm currently learning Python (as a beginner in programming). I go through each chapter learning basics. I haven't gotten far enough to understand how CMS works. I eventually want a blog that doesn't depend on Wordpress or Drupal. I would like to develop it myself as my skills progress. My immediate curiosity is on blog posts. What is the component called that will allow me to make a daily post on my blog? There must be a technical term for this function. I would like to learn how to make one, but don't even know what to research. Everything I research points me to Wordpress or Drupal. I would like to create my own. Thanks in advance! Ali

    Read the article

  • Drupal 7 : vers la sortie de la version finale le 5 Janvier, la 3ème et dernière release candidate du CMS open-source est disponible

    Drupal 7 : vers une sortie de la version finale le 5 Janvier La 3ème et dernière RC du système de gestion de contenu open-source est disponible Mise à jour du 27/12/2010 par Idelways L'équipe de Drupal vient de sortir la troisième et (à priori) dernière release-candidate de la version 7 du système de gestion de contenu open-source. Dries Buytaert, le créateur du CMS a par ailleurs annoncé sur son blog que le 5 janvier prochain sera la date de sortie de la version finale, il promet une "fête gigantesque" pour célébrer cet évènement. Avec cette troisième RC, le CMS retrouve le statu de zéro failles...

    Read the article

  • Drupal 7 : vers la sortie de la version finale le 5 janvier, la 3e et dernière Release Candidate du CMS open-source est disponible

    Drupal 7 : vers une sortie de la version finale le 5 Janvier La 3ème et dernière RC du système de gestion de contenu open-source est disponible Mise à jour du 27/12/2010 par Idelways L'équipe de Drupal vient de sortir la troisième et (à priori) dernière release-candidate de la version 7 du système de gestion de contenu open-source. Dries Buytaert, le créateur du CMS a par ailleurs annoncé sur son blog que le 5 janvier prochain sera la date de sortie de la version finale, il promet une "fête gigantesque" pour célébrer cet évènement. Avec cette troisième RC, le CMS retrouve le statut de zéro faille...

    Read the article

  • Use date operations on a computed field filter in a view

    - by stephenhay
    I'd like to expose a filter in Views based on a Computed Field. This field should utilize the date operation "less than". Apparently, a date type is not available to computed field (varchar is). However, using varchar results in views treating the field as a string rather than as a date, without the operation I'm looking for. So I tried using a timestamp instead of a date, which allowed me to use an integer data type. The exposed view gives me a "less than" operation, but as it's still not a date, the user must type in a timestamp. Not handy. So I'm thinking the best way to do this is to create a new (hidden) CCK field which is a date field, and set the value of this field to the value of the Computed Field. I can then use the new CCK field for my exposed filter. But I'm not getting anywhere with this, as I'm unsure how to set another CCK field with a Computed Field. To return the value to the computed field itself, I'm using the standard: $node_field[0]['value'] = $newestdate; I would like to set the value of the new CCK field to $newestdate as well. Can anyone help?

    Read the article

  • Attempting to update partial view using Ajax.ActionLink gives error in MicrosoftAjax.js

    - by mwright
    I am trying to update the partial view ( "OnlyPartialView" ) from an Ajax.ActionLink which is in the same partial view. While executing the foreach loop it throws this error in a popup box in visual studio: htmlfile: Unknown runtime error This error puts the break point in the MicrosoftAjax.js file, Line 5, Col 83,632, Ch 83632. The page is not updated appropriately. Any thoughts or ideas on how I could troubleshoot this? It was previously nested partial views, I've simplified it for this example but this code produces the same error. Is there a better way to do what I am trying to do? Index Page: <script src="../../Scripts/MicrosoftAjax.js" type="text/javascript"></script> <script src="../../Scripts/MicrosoftMvcAjax.js" type="text/javascript"></script> <ul> <% foreach (DomainObject domainObject in Model) { %> <% Html.RenderPartial("OnlyPartialView", domainObject); %> <% } %> </ul> OnlyPartialView: <%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl<ProjectName.Models.DomainObject>" %> <%@ Import Namespace="ProjectName.Models"%> <li> <div id="<%=Model.Id%>"> //DISPLAY ATTRIBUTES </div> <div id="<%= Model.Id %>ActionStateLinks"> <% foreach ( var actionStateLink in Model.States[0].State.ActionStateLinks) {%> <div id="Div1"> <div> <%= actionStateLink.Action.Name %> </div> <div> <%= Ajax.ActionLink("Submit this Action", "DoAction", "ViewController", new { id = Model.Id, id2 = actionStateLink.ActionStateLinkId }, new AjaxOptions{ UpdateTargetId = Model.Id.ToString()} )%> </div> </div> <br /> <%} %> </div> </li> Controller: public ActionResult DoAction(Guid id, Guid id2) { DomainObject domainObject = _repository.GetDomainObject(id); ActionStateLink actionStateLink = _repository.GetActionStateLink(id2); domainObject.States[0].StateId = actionStateLink.FollowingStateId; repository.AddDomainObjectAction(domainObject, actionStateLink, DateTime.Now); _repository.Save(); return PartialView("OnlyPartialView", _repository.GetDomainObject(id)); }

    Read the article

  • Evaluating points in time by months, but without referencing years in Rails

    - by MikeH
    FYI, There is some overlap in the initial description of this question with a question I asked yesterday, but the question is different. My app has users who have seasonal products. When a user selects a product, we allow him to also select the product's season. We accomplish this by letting him select a start date and an end date for each product. We're using date_select to generate two sets of drop-downs: one for the start date and one for the end date. Including years doesn't make sense for our model. So we're using the option: discard_year => true When you use discard_year => true, Rails sets a year in the database, it just doesn't appear in the views. Rails sets all the years to either 0001 or 0002 in our app. Yes, we could make it 2009 and 2010 or any other pair. But the point is that we want the months and days to function independent of a particular year. If we used 2009 and 2010, then those dates would be wrong next year because we don't expect these records to be updated every year. My problem is that we need to dynamically evaluate the availability of products based on their relationship to the current month. For example, assume it's March 15. Regardless of the year, I need a method that can tell me that a product available from October to January is not available right now. If we were using actual years, this would be pretty easy. For example, in the products model, I can do this: def is_available? (season_start.past? && season_end.future?) end I can also evaluate a start_date and an end_date against current_date However, in setup I've described above where we have arbitrary years that only make sense relative to each other, these methods don't work. For example, is_available? would return false for all my products because their end date is in the year 0001 or 0002. What I need is a method just like the ones I used as examples above, except that they evaluate against current_month instead of current_date, and past? and future months instead of years. I have no idea how to do this or whether Rails has any built in functionality that could help. I've gone through all the date and time methods/helpers in the API docs, but I'm not seeing anything equivalent to what I'm describing. Thanks.

    Read the article

  • ASP.NET MVC CRUD PartialView Popup Issue

    - by Smiley Face
    I am creating an MVC website which makes use of Partial Views on Popups to handle all my CRUD transactions. Please note that my application can already handle these CRUD operations perfectly (LINQ-To-Entity). However, I have a problem with my popup forms. Below is the code from my _Add.cshtml: @model MyStore.Models.MyModels.ProductsModel @{ Layout = null; } @using (Ajax.BeginForm("_Add", "Products", new AjaxOptions { InsertionMode = InsertionMode.Replace, HttpMethod = "POST", OnSuccess = "addSuccess" }, new { @id = "addForm" })) { @Html.ValidationSummary(true) <div id="add-message" class="error invisible"></div> <fieldset> <legend>Products</legend> @Html.HiddenFor(m => Model.ProductCode) <div class="editor-label"> @Html.LabelFor(model => model.ProductName) </div> <div class="editor-field"> @Html.EditorFor(model => model.ProductName) @Html.ValidationMessageFor(model => model.ProductName) </div> <div class="editor-label"> @Html.LabelFor(model => model.Price) </div> <div class="editor-field"> @Html.TextBoxFor(model => model.Price) @Html.ValidationMessageFor(model => model.Price) </div> </fieldset> } Below is the code from my Controller: [HttpGet] public ActionResult _Add(string productCode) { ProductsModel model = newProductsModel(); model.ProductCode = ProductCode ; return PartialView(model); } [HttpPost] public JsonResult _Add(ProductsModel model) { if (ModelState.IsValid) { ProductsManager prod = new ProductsManager(); Products pa = new Products(); pa.ProductCode = model.ProductCode; pa.ProductName = model.ProductName; pa.Price = model.Price; prod.AddProduct(pa); return Json(HelperClass.SuccessResponse(pa), JsonRequestBehavior.AllowGet); } else { return Json(HelperClass.ErrorResponse("Please review your form"), JsonRequestBehavior.DenyGet); } } Please note that the _Add.cshtml is a partial view which is being rendered through a Popup.js which I found on the internet. It is rendered through this code: @Html.ActionLink("[Add Product]", "_Add", new { ProductCode = @ViewData["ProductCode"] }, new { @class = "editLink" }) This works okay. I mean it adds product to my database. But my problem is upon clicking the Proceed button, I get this pop-up download dialog from the page: Can somebody please help me with this? I have a hunch it's because of the HttpMethod i'm using (POST, PUT, GET, DELETE) but i'm not really sure which one is right to use or if it really is the problem in the first place. Any help would be greatly appreciated! PS. Sorry for the long post.

    Read the article

  • The backbone router isn't working properly

    - by user2473588
    I'm building a simple backbone app that have 4 routes: home, about, privacy and terms. But after setting the routes I have 3 problems: The "terms" view isn't rendering; When I refresh the #about or the #privacy page, the home view renders after the #about/#privacy view When I hit the back button the home view never renders. For example, if I'm in the #about page, and I hit the back button to the homepage, the about view stays in the page I don't know what I'm doing wrong about the 1st problem. I think that the 2nd and 3rd problem are related with something missing in the home router, but I don't know what is. Here is my code: HTML <section class="feed"> <script id="homeTemplate" type="text/template"> <div class="home"> </div> </script> <script id="termsTemplate" type="text/template"> <div class="terms"> Bla bla bla bla </div> </script> <script id="privacyTemplate" type="text/template"> <div class="privacy"> Bla bla bla bla </div> </script> <script id="aboutTemplate" type="text/template"> <div class="about"> Bla bla bla bla </div> </script> </section> The views app.HomeListView = Backbone.View.extend({ el: '.feed', initialize: function ( initialbooks ) { this.collection = new app.BookList (initialbooks); this.render(); }, render: function() { this.collection.each(function( item ){ this.renderHome( item ); }, this); }, renderHome: function ( item ) { var bookview = new app.BookView ({ model: item }) this.$el.append( bookview.render().el ); } }); app.BookView = Backbone.View.extend ({ tagName: 'div', className: 'home', template: _.template( $( '#homeTemplate' ).html()), render: function() { this.$el.html(this.template(this.model.toJSON())); return this; } }); app.AboutView = Backbone.View.extend({ tagName: 'div', className: 'about', initialize:function () { this.render(); }, template: _.template( $( '#aboutTemplate' ).html()), render: function () { this.$el.html(this.template()); return this; } }); app.PrivacyView = Backbone.View.extend ({ tagName: 'div', className: 'privacy', initialize: function() { this.render(); }, template: _.template( $('#privacyTemplate').html() ), render: function () { this.$el.html(this.template()); return this; } }); app.TermsView = Backbone.View.extend ({ tagName: 'div', className: 'terms', initialize: function () { this.render(); }, template: _.template ( $( '#termsTemplate' ).html() ), render: function () { this.$el.html(this.template()), return this; } }); And the router: var AppRouter = Backbone.Router.extend({ routes: { '' : 'home', 'about' : 'about', 'privacy' : 'privacy', 'terms' : 'terms' }, home: function () { if (!this.homeListView) { this.homeListView = new app.HomeListView(); }; }, about: function () { if (!this.aboutView) { this.aboutView = new app.AboutView(); }; $('.feed').html(this.aboutView.el); }, privacy: function () { if (!this.privacyView) { this.privacyView = new app.PrivacyView(); }; $('.feed').html(this.privacyView.el); }, terms: function () { if (!this.termsView) { this.termsView = new app.TermsView(); }; $('.feed').html(this.termsView.el); } }) app.Router = new AppRouter(); Backbone.history.start(); I'm missing something but I don't know what. Thanks

    Read the article

  • CakePHP access indirectly related model - beginner's question

    - by user325077
    Hi everyone, I am writing a CakePHP application to log the work I do for various clients, but after trying for days I seem unable to get it to do what I want. I have read most of the book CakePHP's website. and googled for all I'm worth, so I presume I am missing something obvious! Every 'log item' belongs to a 'sub-project, which in turn belongs to a 'project', which in turn belongs to a 'sub-client' which finally belongs to a client. These are the 5 MySQL tables I am using: mysql> DESCRIBE log_items; +-----------------+--------------+------+-----+---------+----------------+ | Field | Type | Null | Key | Default | Extra | +-----------------+--------------+------+-----+---------+----------------+ | id | int(11) | NO | PRI | NULL | auto_increment | | date | date | NO | | NULL | | | time | time | NO | | NULL | | | time_spent | int(11) | NO | | NULL | | | sub_projects_id | int(11) | NO | MUL | NULL | | | title | varchar(100) | NO | | NULL | | | description | text | YES | | NULL | | | created | datetime | YES | | NULL | | | modified | datetime | YES | | NULL | | +-----------------+--------------+------+-----+---------+----------------+ mysql> DESCRIBE sub_projects; +-------------+--------------+------+-----+---------+----------------+ | Field | Type | Null | Key | Default | Extra | +-------------+--------------+------+-----+---------+----------------+ | id | int(11) | NO | PRI | NULL | auto_increment | | name | varchar(100) | NO | | NULL | | | projects_id | int(11) | NO | MUL | NULL | | | created | datetime | YES | | NULL | | | modified | datetime | YES | | NULL | | +-------------+--------------+------+-----+---------+----------------+ mysql> DESCRIBE projects; +----------------+--------------+------+-----+---------+----------------+ | Field | Type | Null | Key | Default | Extra | +----------------+--------------+------+-----+---------+----------------+ | id | int(11) | NO | PRI | NULL | auto_increment | | name | varchar(100) | NO | | NULL | | | sub_clients_id | int(11) | NO | MUL | NULL | | | created | datetime | YES | | NULL | | | modified | datetime | YES | | NULL | | +----------------+--------------+------+-----+---------+----------------+ mysql> DESCRIBE sub_clients; +------------+--------------+------+-----+---------+----------------+ | Field | Type | Null | Key | Default | Extra | +------------+--------------+------+-----+---------+----------------+ | id | int(11) | NO | PRI | NULL | auto_increment | | name | varchar(100) | NO | | NULL | | | clients_id | int(11) | NO | MUL | NULL | | | created | datetime | YES | | NULL | | | modified | datetime | YES | | NULL | | +------------+--------------+------+-----+---------+----------------+ mysql> DESCRIBE clients; +----------+--------------+------+-----+---------+----------------+ | Field | Type | Null | Key | Default | Extra | +----------+--------------+------+-----+---------+----------------+ | id | int(11) | NO | PRI | NULL | auto_increment | | name | varchar(100) | NO | | NULL | | | created | datetime | YES | | NULL | | | modified | datetime | YES | | NULL | | +----------+--------------+------+-----+---------+----------------+ I have set up the following associations in CakePHP: LogItem belongsTo SubProjects SubProject belongsTo Projects Project belongsTo SubClients SubClient belongsTo Clients Client hasMany SubClients SubClient hasMany Projects Project hasMany SubProjects SubProject hasMany LogItems Using 'cake bake' I have created the models, controllers (index, view add, edit and delete) and views, and things seem to function - as in I am able to perform simple CRUD operations successfully. The Question When editing a 'log item' at www.mydomain/log_items/edit I am presented with the view you would all suspect; namely the columns of the log_items table with the appropriate textfields/select boxes etc. I would also like to incorporate select boxes to choose the client, sub-client, project and sub-project in the 'log_items' edit view. Ideally the 'sub-client' select box should populate itself depending upon the 'client' chosen, the 'project' select box should also populate itself depending on the 'sub-client' selected etc, etc. I guess the way to go about populating the select boxes with relevant options is Ajax, but I am unsure of how to go about actually accessing a model from the child view of a indirectly related model, for example how to create a 'sub-client' select box in the 'log_items' edit view. I have have found this example: http://forum.phpsitesolutions.com/php-frameworks/cakephp/ajax-cakephp-dynamically-populate-html-select-dropdown-box-t29.html where someone achieves something similar for US states, counties and cities. However, I noticed in the database schema - which is downloadable from the site above link - that the database tables don't have any foreign keys, so now I'm wondering if I'm going about things in the correct manner. Any pointers and advice would be very much appreciated. Kind regards, Chris

    Read the article

  • Repopulating a collection of Backbone forms with previously submitted data

    - by Brian Wheat
    I am able to post my forms to my database and I have stepped through my back end function to check and see that my Get function is returning the same data I submitted. However I am having trouble understanding how to have this data rendered upon visiting the page again. What am I missing? The intention is to be able to create, read, update, or delete (CRUD) some personal contact data for a variable collection of individuals. //Model var PersonItem = Backbone.Model.extend({ url: "/Application/PersonList", idAttribute: "PersonId", schema: { Title: { type: 'Select', options: function (callback) { $.getJSON("/Application/GetTitles/").done(callback); } }, Salutation: { type: 'Select', options: ['Mr.', 'Mrs.', 'Ms.', 'Dr.'] }, FirstName: 'Text', LastName: 'Text', MiddleName: 'Text', NameSuffix: 'Text', StreetAddress: 'Text', City: 'Text', State: { type: 'Select', options: function (callback) { $.getJSON("/Application/GetStates/").done(callback); } }, ZipCode: 'Text', PhoneNumber: 'Text', DateOfBirth: 'Date', } }); Backbone.Form.setTemplates(template, PersonItem); //Collection var PersonList = Backbone.Collection.extend({ model: PersonItem , url: "/Application/PersonList" }); //Views var PersonItemView = Backbone.Form.extend({ tagName: "li", events: { 'click button.delete': 'remove', 'change input': 'change' }, initialize: function (options) { console.log("ItemView init"); PersonItemView.__super__.initialize.call(this, options); _.bindAll(this, 'render', 'remove'); console.log("ItemView set attr = " + options); }, render: function () { PersonItemView.__super__.render.call(this); $('fieldset', this.el).append("<button class=\"delete\" style=\"float: right;\">Delete</button>"); return this; }, change: function (event) { var target = event.target; console.log('changing ' + target.id + ' from: ' + target.defaultValue + ' to: ' + target.value); }, remove: function () { console.log("delete button pressed"); this.model.destroy({ success: function () { alert('person deleted successfully'); } }); return false; } }); var PersonListView = Backbone.View.extend({ el: $("#application_fieldset"), events: { 'click button#add': 'addPerson', 'click button#save': 'save2db' }, initialize: function () { console.log("PersonListView Constructor"); _.bindAll(this, 'render', 'addPerson', 'appendItem', 'save'); this.collection = new PersonList(); this.collection.bind('add', this.appendItem); //this.collection.fetch(); this.collection.add([new PersonItem()]); console.log("collection length = " + this.collection.length); }, render: function () { var self = this; console.log(this.collection.models); $(this.el).append("<button id='add'>Add Person</button>"); $(this.el).append("<button id='save'>Save</button>"); $(this.el).append("<fieldset><legend>Contact</legend><ul id=\"anchor_list\"></ul>"); _(this.collection.models).each(function (item) { self.appendItem(item); }, this); $(this.el).append("</fieldset>"); }, addPerson: function () { console.log("addPerson clicked"); var item = new PersonItem(); this.collection.add(item); }, appendItem: function (item) { var itemView = new PersonItemView({ model: item }); $('#anchor_list', this.el).append(itemView.render().el); }, save2db: function () { var self = this; console.log("PersonListView save"); _(this.collection.models).each(function (item) { console.log("item = " + item.toJSON()); var cid = item.cid; console.log("item.set"); item.set({ Title: $('#' + cid + '_Title').val(), Salutation: $('#' + cid + '_Salutation').val(), FirstName: $('#' + cid + '_FirstName').val(), LastName: $('#' + cid + '_LastName').val(), MiddleName: $('#' + cid + '_MiddleName').val(), NameSuffix: $('#' + cid + '_NameSuffix').val(), StreetAddress: $('#' + cid + '_StreetAddress').val(), City: $('#' + cid + '_City').val(), State: $('#' + cid + '_State').val(), ZipCode: $('#' + cid + '_ZipCode').val(), PhoneNumber: $('#' + cid + '_PhoneNumber').val(), DateOfBirth: $('#' + cid + '_DateOfBirth').find('input').val() }); if (item.isNew()) { console.log("item.isNew"); self.collection.create(item); } else { console.log("!item.isNew"); item.save(); } }); return false; } }); var personList = new PersonList(); var view = new PersonListView({ collection: personList }); personList.fetch({ success: function () { $("#application_fieldset").append(view.render()); } });

    Read the article

  • Is memcache impacting my performence negatively?

    - by iTech
    I am using pressflow 6 and NewRelic seems to suggest that memcache is infact hurting performance as shown below : My settings.php file : # Varnish reverse proxy on localhost $conf['reverse_proxy'] = TRUE; $conf['reverse_proxy_addresses'] = array('127.0.0.1'); # Memcached configuration $conf['cache_inc'] = './sites/all/modules/memcache/memcache.inc'; $conf['memcache_servers'] = array( '127.0.0.1:11211' => 'default', ); ### END Mercury settings written on 2011-11-01T07:12:49-04:00

    Read the article

  • duplicate cache pages: Varnish

    - by Sukhjinder Singh
    Recently we have configured Varnish on our server, it was successfully setup but we noticed that if we open any page in multiple browsers, the Varnish send request to Apache not matter page is cached or not. If we refresh twice on each browser it creates duplicate copies of the same page. What exactly should happen: If any page is cached by Varnish, the subsequent request should be served from Varnish itself when we are opening the same page in browser OR we are opening that page from different IP address. Following is my default.vcl file backend default { .host = "127.0.0.1"; .port = "80"; } sub vcl_recv { if( req.url ~ "^/search/.*$") { }else { set req.url = regsub(req.url, "\?.*", ""); } if (req.restarts == 0) { if (req.http.x-forwarded-for) { set req.http.X-Forwarded-For = req.http.X-Forwarded-For + ", " + client.ip; } else { set req.http.X-Forwarded-For = client.ip; } } if (!req.backend.healthy) { unset req.http.Cookie; } set req.grace = 6h; if (req.url ~ "^/status\.php$" || req.url ~ "^/update\.php$" || req.url ~ "^/admin$" || req.url ~ "^/admin/.*$" || req.url ~ "^/flag/.*$" || req.url ~ "^.*/ajax/.*$" || req.url ~ "^.*/ahah/.*$") { return (pass); } if (req.url ~ "(?i)\.(pdf|asc|dat|txt|doc|xls|ppt|tgz|csv|png|gif|jpeg|jpg|ico|swf|css|js)(\?.*)?$") { unset req.http.Cookie; } if (req.http.Cookie) { set req.http.Cookie = ";" + req.http.Cookie; set req.http.Cookie = regsuball(req.http.Cookie, "; +", ";"); set req.http.Cookie = regsuball(req.http.Cookie, ";(SESS[a-z0-9]+|SSESS[a-z0-9]+|NO_CACHE)=", "; \1="); set req.http.Cookie = regsuball(req.http.Cookie, ";[^ ][^;]*", ""); set req.http.Cookie = regsuball(req.http.Cookie, "^[; ]+|[; ]+$", ""); if (req.http.Cookie == "") { unset req.http.Cookie; } else { return (pass); } } if (req.request != "GET" && req.request != "HEAD" && req.request != "PUT" && req.request != "POST" && req.request != "TRACE" && req.request != "OPTIONS" && req.request != "DELETE") {return(pipe);} /* Non-RFC2616 or CONNECT which is weird. */ if (req.request != "GET" && req.request != "HEAD") { return (pass); } if (req.http.Accept-Encoding) { if (req.url ~ "\.(jpg|png|gif|gz|tgz|bz2|tbz|mp3|ogg)$") { # No point in compressing these remove req.http.Accept-Encoding; } else if (req.http.Accept-Encoding ~ "gzip") { set req.http.Accept-Encoding = "gzip"; } else if (req.http.Accept-Encoding ~ "deflate") { set req.http.Accept-Encoding = "deflate"; } else { # unknown algorithm remove req.http.Accept-Encoding; } } return (lookup); } sub vcl_deliver { if (obj.hits > 0) { set resp.http.X-Varnish-Cache = "HIT"; } else { set resp.http.X-Varnish-Cache = "MISS"; } } sub vcl_fetch { if (beresp.status == 404 || beresp.status == 301 || beresp.status == 500) { set beresp.ttl = 10m; } if (req.url ~ "(?i)\.(pdf|asc|dat|txt|doc|xls|ppt|tgz|csv|png|gif|jpeg|jpg|ico|swf|css|js)(\?.*)?$") { unset beresp.http.set-cookie; } set beresp.grace = 6h; } sub vcl_hash { hash_data(req.url); if (req.http.host) { hash_data(req.http.host); } else { hash_data(server.ip); } return (hash); } sub vcl_pipe { set req.http.connection = "close"; } sub vcl_hit { if (req.request == "PURGE") {ban_url(req.url); error 200 "Purged";} if (!obj.ttl > 0s) {return(pass);} } sub vcl_miss { if (req.request == "PURGE") {error 200 "Not in cache";} }

    Read the article

  • What is excessive swapping.

    - by amateur barista
    This post led me to ask that question. Cache contention On a large site, if you are using MyISAM, contention occurs in the database tables when the cache is forced to clear after a node or a comment is added. With tens of thousands of filter text snippets needing to be deleted, the table will be locked for a long period, and any accesses to it will be queued pending the purge of the data in it. The same is true for the page cache as well. This often causes a "site hang" for a minute or two. During that time new requests keep piling up, and if you do not have the MaxClients parameter in Apache setup correctly, the system can go into thrashing because of excessive swapping.

    Read the article

  • Auto restart server if virtual memory is too low

    - by Sukhjinder Singh
    There are quite number of software running on my server: httpd, varnish, mysql, memcache, java.. Each of them is using a part of the virtual memory and varnish was configured to be allocated 3GB of memory to run. Due to high traffic load which is 100K, our server ran out of memory and oom-killer is invoked. We've to reboot the server. We have 8GB of Virtual Memory and due to some reason we cannot extend to larger memory. My question is - Is there any automated script, which will monitor how much virtual memory left and based upon certain criteria, lets say if 500MB left than restart the server automatically? I do know this is not the proper solution but we have to do it, otherwise we don't know when server will get OOM and by the time we know and restart the server, we lost our visiting users.

    Read the article

  • How do I display many images (by imagefield) in all my nodes of a type?

    - by Leon
    The thing is that I have hundreds of nodes each with 4 to 12 images all of them around the same size in an imagefield but I want to order that so it looks at the end in a grid or something like that. I know that panels and views are the answer but I think I've seen all of the tutorials available but nothing. If anyone know where can I find something like I need, I'll be very gratefull.

    Read the article

  • php Access violation

    - by drzhivago
    I am trying to install Php on Vista (IIS 7). The installation and configuration seems to be fine. Pretty much followed everything mentioned in http://blogs.iis.net/bills/archive/2006/09/19/How-to-install-PHP-on-IIS7-_2800_RC1_2900_.aspx I can even bring up a test.php which is basically and can also connect to mysql db through code. But when I try to bring up some other php page like drupal's index page or phpmyadmin index page, it brings up a Php access violation message. Any clue whats happening? Also is there some tracing/diagnositic tool for php to trace whats happenign on the webserver.

    Read the article

  • How to time-delay email deliveries?

    - by Michael D
    I'm currently learning about the Drupal email functions, such as drupal_mail and hook_mail, and hook_mail_alter, and I have a problem before me where I'll need to be able to queue emails for delayed delivery. For example, an event signup notification that needs to wait for an hour after the event was registered by a user. And that email has user specific data, so can't be just a generic template email... I'm using the MailQ module, mainly for it's logging capabilities, but I wonder if it (or something else) could be modified to add a configurable delay function? Any ideas?

    Read the article

  • Can't get max_post_size php variable set in lunar pages.

    - by Behrooz Karjooravary
    I need to increase max post size and upload size for php to use the audio module of drupal. I read this has to be set in php.ini. However I don't think I have access to that file in lunar pages. I also read it can also be set in .htaccess. However it doesn't change anything. I tried: php_value post_max_size "40M" php_value upload_max_filesize "40M" i also tried: php_value post_max_size 40M php_value upload_max_filesize 40M On localhost it says restart webserver. But this is not possible on shared host. Could that be the problem?

    Read the article

  • .htaccess : Forward any link to /index.htm

    - by Kevin
    Hey all, I'd like to do the following: If a user gets to a url or types it in, and it is along the lines of any the following: /path/path/path /path /path/path/ I would like htaccess to forward them to that url + /index.htm before triggering a 404. Also, I would like to ignore this rule for certain paths. Here is what I was trying and wasn't having success: RewriteCond %{REQUEST_URI} !^(admin) RewriteCond %{REQUEST_URI} !^(node) RewriteRule ^/(.*)/$ $1/index.htm [L] Here is how the app is outlined. It is actually a subdirectory within an application as the site is in transition at the moment. ParentApp/ /folder/ /folder/ /Drupal/ /(new application here) /... /...

    Read the article

< Previous Page | 63 64 65 66 67 68 69 70 71 72 73 74  | Next Page >