ExpressionEngine CMS
Open, Free, Amazing

Thread

This is an archived forum and the content is probably no longer relevant, but is provided here for posterity.

The active forums are here.

To Java or not to Java?

January 11, 2009 12:09pm

Subscribe [4]
  • #1 / Jan 11, 2009 12:09pm

    Herb

    224 posts

    In a nutshell, I am toying with the idea of having java pop-up comment form instead of moving to a new page request.

    The problem I see with java is that you don’t know if the visitor has java enabled or not; resulting in the need to have the java pop-up (if java is enabled) or a link for a new page request (if java is not enabled).

    I’ve thought about having the pop-up link in a hidden div and the link for new page in a visible div and switching their visible property with java; however, this would would require placing the pop-up form in the html irregardless of java enabled state.

    So…. the $64 questions are:

    Does anyone have a cleaner way to handle this?

            -or-

    Should I just skip the cute java thing and stay traditional with just moving to a new page for comment entry?

  • #2 / Jan 11, 2009 12:25pm

    Riverboy

    2993 posts

    I dont know the answer but look at your statistic if you are working with the live site. I have 6,28 % in the case of “non-java” so i could keep few users but it is for me, more or less -not so important- to think about those 6%. Sure my advice is to go with the solid solution that works to all and drop out some nice little things to keep the users coming!

  • #3 / Jan 11, 2009 12:57pm

    are you really wanting to use java or do you mean javascript? there is a big difference. i’m guessing the latter. if that is indeed the case, then you could possibly have your cake and eat it too by using some combination of js and ee conditionals. if the person has js enabled then the content gets displayed how you want. if not, then it defaults to a new page.

  • #4 / Jan 11, 2009 1:55pm

    Herb

    224 posts

    Thanks for the replies.

    Yes I meant javascript, jQuery specifically.  I guess where I’m having problems on how to implement this is that I’m having problems wrapping my head around the sequence of events in your suggestion

    i’m guessing the latter. if that is indeed the case, then you could possibly have your cake and eat it too by using some combination of js and ee conditionals. if the person has js enabled then the content gets displayed how you want. if not, then it defaults to a new page.

    Since the page is already rendered by the time the javascript is executed how would an ee conditional process the result of the javascript or not?  What would be the trigger?

    I could see passing the nonjava page with a javascript to redirect to a java page; but, I’m trying to reduce page requests.  I guess I could detect java enabled at some earlier point and set a session variable; but, that doesn’t address a user landing directly on the current page through a bookmark or whatever.

    Any thoughts?

  • #5 / Jan 11, 2009 4:00pm

    asozzi

    262 posts

    I think I may be able to elaborate a bit.
    (but first, could you please refrain from mingling java and javaScript names? It gives me the shivers…)

    What you are looking for is so called progressive enhancement and jQuery is a very good tool for that. Essentially jQuery changes the page after loading, so what you want to do is to construct the page in the standard way as your base page. I.e build your EE page template as usual. This page now works for everybody,even if they have javaScript disabled.

    Now you start to enhance the page. There are several methods: you could place the form in HTML Noscript tags (only show the form if the browser does not support or has disabled javascript). Or you can use jQuery to toggle the forms class to “hide” (hides only if JS is enabled). I don’t think you need to do this in EE, since that makes thinks more complicated.
    (I guess the issue is one of logic clauses, which is not helped by the use of non-words such as irregardless ( a double negative) 😉


    Then you have to re-create the submission form for AJAX (see the progressive enhancement link for some pointers).
    Generally speaking you may want to now use jQuery to insert the “new” link that triggers the popup (you may want to use a so called modal, instead of a separate popup window. I also remember some threads dealing with this in the forum.

  • #6 / Jan 11, 2009 4:24pm

    Herb

    224 posts

    Many thanks asozzi:

    Great pointer.  I think you have given me enough ammunition to attack this.  My goal is to be able to serve up an intelligent app and this seems to be the way to go.  I haven’t used ajax before; but, there is no time like the present to learn new tricks.

.(JavaScript must be enabled to view this email address)

ExpressionEngine News!

#eecms, #events, #releases