Search Results

Search found 3 results on 1 pages for 'mikew'.

Page 1/1 | 1 

  • how to reapply knockout binding

    - by MikeW
    Currently I have a knockout binding that stripes rows in a list which works fine ko.bindingHandlers.stripe = { update: function (element, valueAccessor, allBindingsAccessor) { var value = ko.utils.unwrapObservable(valueAccessor()); //creates the dependency var allBindings = allBindingsAccessor(); var even = allBindings.evenClass; var odd = allBindings.oddClass; //update odd rows $(element).children(":nth-child(odd)").addClass(odd).removeClass(even); //update even rows $(element).children(":nth-child(even)").addClass(even).removeClass(odd); ; } } Triggered from <button data-bind="click: addWidget" style="display:none">Add Item</button> The problem I have is when reloading data from the server , I call addWidget() manually in the view model the stripe binding handler is not applied - all rows appear as same color, if I click the html button then the binding happens and stripes appear var ViewModel = function() { self.addWidget(); }); Is it possible to reapply this custom binding manually in js? Thanks Edit: The stripe binding gets applied like so <div data-bind="foreach: widgets, stripe: widgets, evenClass: 'light', oddClass: 'dark'">

    Read the article

  • c# event fires windows form incorrectly

    - by MikeW
    I'm trying to understand what's happening here. I have a CheckedListBox which contains some ticked and some un-ticked items. I'm trying to find a way of determining the delta in the selection of controls. I've tried some cumbersome like this - but only works part of the time, I'm sure there's a more elegant solution. A maybe related problem is the myCheckBox_ItemCheck event fires on form load - before I have a chance to perform an ItemCheck. Here's what I have so far: void clbProgs_ItemCheck(object sender, ItemCheckEventArgs e) { // i know its awful System.Windows.Forms.CheckedListBox cb = (System.Windows.Forms.CheckedListBox)sender; string sCurrent = e.CurrentValue.ToString(); int sIndex = e.Index; AbstractLink lk = (AbstractLink)cb.Items[sIndex]; List<ILink> _links = clbProgs.DataSource as List<ILink>; foreach (AbstractLink lkCurrent in _links) { if (!lkCurrent.IsActive) { if (!_groupValues.ContainsKey(lkCurrent.Linkid)) { _groupValues.Add(lkCurrent.Linkid, lkCurrent); } } } if (_groupValues.ContainsKey(lk.Linkid)) { AbstractLink lkDirty = (AbstractLink)lk.Clone(); CheckState newValue = (CheckState)e.NewValue; if (newValue == CheckState.Checked) { lkDirty.IsActive = true; } else if (newValue == CheckState.Unchecked) { lkDirty.IsActive = false; } if (_dirtyGroups.ContainsKey(lk.Linkid)) { _dirtyGroups[lk.Linkid] = lkDirty; } else { CheckState oldValue = (CheckState)e.NewValue; if (oldValue == CheckState.Checked) { lkDirty.IsActive = true; } else if (oldValue == CheckState.Unchecked) { lkDirty.IsActive = false; } _dirtyGroups.Add(lk.Linkid, lk); } } else { if (!lk.IsActive) { _dirtyGroups.Add(lk.Linkid, lk); } else { _groupValues.Add(lk.Linkid, lk); } } } Then onclick of a save button - I check whats changed before sending to database: private void btSave_Click(object sender, EventArgs e) { List<AbstractLink> originalList = new List<AbstractLink>(_groupValues.Values); List<AbstractLink> changedList = new List<AbstractLink>(_dirtyGroups.Values); IEnumerable<AbstractLink> dupes = originalList.ToArray<AbstractLink>().Intersect(changedList.ToArray<AbstractLink>()); foreach (ILink t in dupes) { MessageBox.Show("Changed"); } if (dupes.Count() == 0) { MessageBox.Show("No Change"); } } For further info. The definition of type AbstractLink uses: public bool Equals(ILink other) { if (Object.ReferenceEquals(other, null)) return false; if (Object.ReferenceEquals(this, other)) return true; return IsActive.Equals(other.IsActive) && Linkid.Equals(other.Linkid); }

    Read the article

  • Robotlegs: Warning: Injector already has a rule for type

    - by MikeW
    I have a bunch of warning messages like this appear when using Robotlegs/Signals. Everytime this command class executes, which is every 2-3 seconds ..this message displays below If you have overwritten this mapping intentionally you can use "injector.unmap()" prior to your replacement mapping in order to avoid seeing this message. Warning: Injector already has a rule for type "mx.messaging.messages::IMessage", named "". The command functions fine otherwise but I think I'm doing something wrong anyhow. public class MessageReceivedCommand extends SignalCommand { [Inject] public var message:IMessage; ...etc.. do something with message.. } the application context doesnt map IMessage to this command, as I only see an option to mapSignalClass , besides the payload is received fine. Wonder if anyone knows how I might either fix or suppress this message. I've tried calling this as the warning suggests injector.unmap(IMessage, "") but I receive an error - no mapping found for ::IMessage named "". Thanks Edit: A bit more info about the error Here is the signal that I dispatch to the command public class GameMessageSignal extends Signal { public function GameMessageSignal() { super(IMessage); } } which is dispatched from a IPushDataService class gameMessage.dispatch(message.message); and the implementation is wired up in the app context via injector.mapClass(IPushDataService, PushDataService); along with the signal signalCommandMap.mapSignalClass(GameMessageSignal, MessageReceivedCommand); Edit #2: Probably good to point out also I inject an instance of GameMessageSignal into IPushDataService public class PushDataService extends BaseDataService implements IPushDataService { [Inject] public var gameMessage:GameMessageSignal; //then private function processMessage(message:MessageEvent):void { gameMessage.dispatch(message.message); } } Edit:3 The mappings i set up in the SignalContext: injector.mapSingleton(IPushDataService); injector.mapClass(IPushDataService, PushDataService);

    Read the article

1