Search Results

Search found 52 results on 3 pages for 'dreas grech'.

Page 3/3 | < Previous Page | 1 2 3 

  • Jquery toggle event is messing with checkbox value

    - by John McCollum
    Hi all, I'm using Jquery's toggle event to do some stuff when a user clicks a checkbox, like this: $('input#myId').toggle( function(){ //do stuff }, function(){ //do other stuff } ); The problem is that the checkbox isn't being ticked when I click on the checkbox. (All the stuff I've put into the toggle event is working properly.) I've tried the following: $('input#myId').attr('checked', 'checked'); and $(this).attr('checked', 'checked'); and even simply return true; But nothing is working. Can anyone tell me where I'm going wrong? Edit - thanks to all who replied. Dreas' answer very nearly worked for me, except for the part that checked the attribute. This works perfectly (although it's a bit hacky) $('input#myInput').change(function () { if(!$(this).hasClass("checked")) { //do stuff if the checkbox isn't checked $(this).addClass("checked"); return; } //do stuff if the checkbox isn't checked $(this).removeClass('checked'); }); Thanks again to all who replied.

    Read the article

  • WPF MVVM Trigger Animation on MainWindow close

    - by Scott
    I'm using trying to implement MVVM in my app. I have a MainWindow.xaml and a MainWindowViewModel. I'm in the process of removing all of the code-behind code from the MainWindow.xaml but I'm stuck on one final piece. In my pre-MVVM setup I started an animation in the MainWindow.xaml.cs that would fade out the form before closing it. Since Closing is not a RoutedEvent, I had to use code-behind to get this to work. My VM has the following two properties that can be bound: ClosingWindow and CloseWindow. My goal was to bind a DataTrigger in my MainWindowStyle to the ClosingWindow property of the VM. When ClosingWindow was set to True, it would start an animation using the following XAML: <DataTrigger Binding="{Binding ClosingWindow}" Value="True"> <DataTrigger.EnterActions> <BeginStoryboard> <Storyboard> <DoubleAnimation Storyboard.TargetProperty="Opacity" From="1" To="0" Duration="0:0:2"/> </Storyboard> </BeginStoryboard> </DataTrigger.EnterActions> </DataTrigger> Somehow (insert magic here) I was going to set CloseWindow on the VM, via Binding, to True when the animation completed, which would then use an AttachedBehavior to Close the Window. The AttachedBehavior works perfectly when I just set CloseWindow directly using the following XAML: <DataTrigger Binding="{Binding CloseWindow}" Value="True"> <Setter Property="ab:WindowCloseBehavior.Close" Value="True"/> </DataTrigger> ...but I want to reproduce the form fade before the form actually closes. So there are two issues that I've run into: First, the animation doesn't work. I enter the trigger correctly (I've taken out the animation and put a Setter statement in there that changes the Title of the MainWindow to "Closing" and it changes correctly when ClosingWindow = True) but the DoubleAnimation never does anything. Second, there's no way to set the value of CloseWindow once the animation is complete. I looked at Marlon Grech's animation code but that won't work on DataTriggers. I can't publish a RoutedEvent because my VM doesn't descend from UIElement, and I've been Googling all day trying to come up with a clever, MVVM-friendly way to do this with no luck. So any ideas why that animation doesn't do anything? And more importantly, how would you solve the entire problem of animating a form fade on close from the VM? I don't doubt that my entire solution to this problem might be whacked so I'm open to just about anything.

    Read the article

< Previous Page | 1 2 3