Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8295461
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T14:36:01+00:00 2026-06-08T14:36:01+00:00

I have an app with customers who have tasks. To create a new task

  • 0

I have an app with customers who have tasks. To create a new task for a customer you can click a add icon which opens a fancybox with the new task form displayed. This has the following coffee script:

jQuery ->
  $("a.fancyForm").fancybox
  scrolling: "no"
  titleShow: false

However, customers also must have a goal to work towards otherwise the tasks are for nought. So the relationship is really customer has many goals which has many tasks. If the customer already has some goals then the form simply asks you which goal it works towards. If the customer doesn’t have a goal then I want to pop up a confirm box that asks if the user would like to make a goal now. This is the coffee script I currently have:

$("a.noGoals").click (e) ->
  e.preventDefault()
  confirm_create_goal = confirm("There is currently no Goal for this customer. Would you like to create one?")
  if confirm_create_goal
    $("a.noGoals").fancybox()
  else
    alert "You won't be able to create tasks until a goal is created!"

This brings up the confirmation box by click ok appears to do nothing. If you then try a second time it displays the confirmation box and if you click ok or cancel it displays the correct fancybox with my new goal form. How do I get this to work first time round? It seems for the first click of ok it only sets confirm_create_goal and then only opens the fancybox on the second attempt.

If I click “cancel” on the first attempt it correctly displays the alert. Second attempt I hit “ok” no fancybox. Third attempt hit “ok” get fancybox but if I hit “cancel” I get the alert and then fancybox o.O

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-08T14:36:03+00:00Added an answer on June 8, 2026 at 2:36 pm

    So it turns out that calling fancybox as above simply attaches it to the click event, doesn’t call it. So when you click again, regardless of your confirmation box response, it displays the fancybox which is now attached to the click event.

    My solution, although not sure if it’s the best, is to use .on() and .off() to bind and unbind the confirmation box, then I can trigger the fancybox after $(“a.noGoals”).fancybox() call:

    confirm_create_goal = (e) ->
      e.preventDefault()
      confirm_create = confirm("There is currently no Goal for " + $(this).data("customer") + "'s company, " + $(this).data("company") + ". Would you like to create one?")
      if confirm_create
        $("body").off "click", "a.noGoals", confirm_create_goal
        $("a.noGoals").fancybox(onClosed: ->
          $("body").on "click", "a.noGoals", ->
            alert "Create a Goal!"
        ).trigger "click"
      else
        alert "You won't be able to create tasks until a goal is created!"
    
    $("body").on "click", "a.noGoals", confirm_create_goal
    

    So the function confirm_create_goal pops a confirmation box which gives an alert if you hit cancel and if you click ok it unbinds itself from the link, adds fancybox and triggers the click event on the link. This opens the fancybox and everything displays correctly. Finally, I added an alert to bind to the link (in case the user closes the box and tries to make a task) reminding them to create a goal.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

In my play1.2.4 app,I have a Customer who can have a Set of PaymentMethod
I have an app in which customers can partially define their schema by adding
Currently I have this code var App = Ember.Application.create(); App.user = Ember.Object.create({ people: customers
I have an app which uses SQL Express and my customers are mainly people
I have some customers who have volunteered to translate my app's strings into their
I have an app that has a list of items. My customer prefers to
I have a model called Customer in google app engine with python: class Customer(db.Model):
I have a web database app that runs in IE7+ (customer requirement) It is
I have app in which i have recorded sound files i want that i
for example: I have app A, which references library A and library B. in

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.