Results 1 to 7 of 7

Thread: Statement seems to be ignored unless something exec before it.

  1. #1

    Thread Starter
    Hyperactive Member Krokonoster's Avatar
    Join Date
    Jan 2010
    Location
    Cape Town
    Posts
    448

    Statement seems to be ignored unless something exec before it.

    Hi,
    Got 3 cascading dropdowns (Clients -> Departments -> Teams) and loading their data using jquery ajax calls. (there are a lot to the rest of the form though, though not related to this problem )

    Since I am clearing dropdowns and hiding elements all over, I wanted to created a function that can be called any time that will do that in one place). however I soon got stuck.

    The following code works perfectly, until I one uncomment the alert. From then, the next line seems to just get ignored.

    Code:
    function SetControlsVisibility() {
        var clientId = $("select#ClientId > option:selected").attr("value");
        if (clientId == '' || clientId == undefined) {
            alert("abc");
            $('#DepartmentId').empty().prev().text("");   // ain't do it if no alert....
            .....
    got a strong feeling of devaju here, but just cannot remember where I ran into this issue before though.


  2. #2
    MS SQL Powerposter szlamany's Avatar
    Join Date
    Mar 2004
    Location
    Connecticut
    Posts
    18,263

    Re: Statement seems to be ignored unless something exec before it.

    I've also experienced issues like this - not sure how I cleared it up.

    Do you have some kind of missing ; somewhere? I save backup copies of my JS code so I can do a quick WINDIF when something like this happens.

    How about changing your code to this:

    Code:
            var wesDept = $('#DepartmentId');
            wesDept.empty().prev().text("");   // ain't do it if no alert....
    Does that run?

    Can you break/step at that spot with FIREBUG??

    *** Read the sticky in the DB forum about how to get your question answered quickly!! ***

    Please remember to rate posts! Rate any post you find helpful - even in old threads! Use the link to the left - "Rate this Post".

    Some Informative Links:
    [ SQL Rules to Live By ] [ Reserved SQL keywords ] [ When to use INDEX HINTS! ] [ Passing Multi-item Parameters to STORED PROCEDURES ]
    [ Solution to non-domain Windows Authentication ] [ Crazy things we do to shrink log files ] [ SQL 2005 Features ] [ Loading Pictures from DB ]

    MS MVP 2006, 2007, 2008

  3. #3

    Thread Starter
    Hyperactive Member Krokonoster's Avatar
    Join Date
    Jan 2010
    Location
    Cape Town
    Posts
    448

    Re: Statement seems to be ignored unless something exec before it.

    Hi,
    Nope, that seems not to work.

    Unfortunately (NOTE: I quit from this and just working out my notice) the environment I work in, you log into a remote machine, without internet, with vs installed on it. so cannot install firefox, let alone firebug. Have this been on my own machine i probably would sort it out in a few. But crippled like this.


  4. #4
    Frenzied Member
    Join Date
    Apr 2009
    Location
    CA, USA
    Posts
    1,516

    Re: Statement seems to be ignored unless something exec before it.

    This is needlessly convoluted:
    Code:
    var clientId = $("select#ClientId > option:selected").attr("value");
    //equivalent to:
    var clientId = $("#ClientId").val();
    Can't really tell what the problem is; was unable to reproduce it with an assumptive setup. It might help if you can provide more context (the markup and any other related scripting).

  5. #5
    MS SQL Powerposter szlamany's Avatar
    Join Date
    Mar 2004
    Location
    Connecticut
    Posts
    18,263

    Re: Statement seems to be ignored unless something exec before it.

    Quick note on what SambaNeko posted

    Using a SELECTOR of an HTML ID is one of the fastest selectors - jQuery is optimized to locate that DOM element - always DESCEND from an #ID

    http://www.artzstudio.com/2009/04/jq...ormance-rules/

    And note that my wesDept - although not meaningful in this context - is really important to use. Always cache the selection if it's going to be used repeatedly. To me wes stands for "wrapped element set".

    *** Read the sticky in the DB forum about how to get your question answered quickly!! ***

    Please remember to rate posts! Rate any post you find helpful - even in old threads! Use the link to the left - "Rate this Post".

    Some Informative Links:
    [ SQL Rules to Live By ] [ Reserved SQL keywords ] [ When to use INDEX HINTS! ] [ Passing Multi-item Parameters to STORED PROCEDURES ]
    [ Solution to non-domain Windows Authentication ] [ Crazy things we do to shrink log files ] [ SQL 2005 Features ] [ Loading Pictures from DB ]

    MS MVP 2006, 2007, 2008

  6. #6

    Thread Starter
    Hyperactive Member Krokonoster's Avatar
    Join Date
    Jan 2010
    Location
    Cape Town
    Posts
    448

    Re: Statement seems to be ignored unless something exec before it.

    Thanks guys. Will try again tomorrow, strip things down and post some more I cannot solve it.
    Thanks a lot.


  7. #7
    MS SQL Powerposter szlamany's Avatar
    Join Date
    Mar 2004
    Location
    Connecticut
    Posts
    18,263

    Re: Statement seems to be ignored unless something exec before it.

    Did you get a resolution to this??

    *** Read the sticky in the DB forum about how to get your question answered quickly!! ***

    Please remember to rate posts! Rate any post you find helpful - even in old threads! Use the link to the left - "Rate this Post".

    Some Informative Links:
    [ SQL Rules to Live By ] [ Reserved SQL keywords ] [ When to use INDEX HINTS! ] [ Passing Multi-item Parameters to STORED PROCEDURES ]
    [ Solution to non-domain Windows Authentication ] [ Crazy things we do to shrink log files ] [ SQL 2005 Features ] [ Loading Pictures from DB ]

    MS MVP 2006, 2007, 2008

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width