AJAX, Lasso 9.0, Filemaker: How does the Inline fit in?

classic Classic list List threaded Threaded
7 messages Options
Reply | Threaded
Open this post in threaded view
|

AJAX, Lasso 9.0, Filemaker: How does the Inline fit in?

Tom W Robinson
Hello,

Planning on cozying up with a nice jQuery book and some spiked eggnog over the holiday break.  Exciting... I know.

I have working through the "A guide to using Lasso 9.0 and jQuery" and understand the example quite well.  Unfortunately I alos read and understood thoroughly Chapter 53 of the Lasso 8.5 Language Guide  "AJAX and LJAX" and would like to interact with a Filemaker datasource.

I am trying to duplicate the LJAX example in chapter 53 where a simple search form with an input for last name, first name and submit button is AJAX-enabled.

Can anyone point me in the right direction so that I do something similar to the code below in Lasso 9.0?

I assume that in the example below  "... Inline Search Results ..." refers to a standard Inline action?

------------------------------------------------------------------------
<html>
<head>
<title>LJAX Example</title>
<script src=”LJAX.LassoApp” type=”text/javascript”></script>
</head>
<body>
<form response=”[Response_FilePath]” onsubmit=”return !Lasso.includeTarget(‘dynamic’, {args:this});”>
First: <input type=”text” name=”first” value=”[Action_Param: ‘first’]” /><br />
Last: <input type=”text” name=”last” value=”[Action_Param: ‘last’]” /><br />
<input type=”submit” name=”action” value=”Search”/>
</form>
<hr />
[LJAX_Start]
[LJAX_Target: -Target=’dynamic’, -NoTarget]
<div id=”dynamic”>
[If: ((Action_Param: ‘action’) >> ‘search’)]
First: [Action_Param: ‘first’]<br />
Last: [Action_Param: ‘last’]<br />
Date: [Date]
… Inline Search Results …
[/If]
</div>
[/LJAX_Target]
[LJAX_End]
</body>
</html>
------------------------------------------------------------------------

Thanks and Happy Holidays,

Tom Robinson
#############################################################
This message is sent to you because you are subscribed to
  the mailing list Lasso
[hidden email]
To unsubscribe, E-mail to: <[hidden email]>
Send administrative queries to  <[hidden email]>
Reply | Threaded
Open this post in threaded view
|

Re: AJAX, Lasso 9.0, Filemaker: How does the Inline fit in?

Brad Lindsay-2
On Dec 21, 2011, at 7:14 PM, Tom Robinson wrote:
> Hello,
>
> Planning on cozying up with a nice jQuery book and some spiked eggnog over the holiday break.  Exciting... I know.
>
> I have working through the "A guide to using Lasso 9.0 and jQuery" and understand the example quite well.  Unfortunately I alos read and understood thoroughly Chapter 53 of the Lasso 8.5 Language Guide  "AJAX and LJAX" and would like to interact with a Filemaker datasource.
>
> I am trying to duplicate the LJAX example in chapter 53 where a simple search form with an input for last name, first name and submit button is AJAX-enabled.
>
> Can anyone point me in the right direction so that I do something similar to the code below in Lasso 9.0?

Fortunately the LJAX tags do not exist in Lasso 9. As someone who first learned about AJAX through the LJAX tag and then later discovered the wonderfulness of jQuery, let me advise you to stay away from LJAX even in version prior to Lasso 9. Learning a bit of JavaScript and jQuery will serve you much better in the long run and will be easier to implement.

Brad
#############################################################
This message is sent to you because you are subscribed to
  the mailing list Lasso
[hidden email]
To unsubscribe, E-mail to: <[hidden email]>
Send administrative queries to  <[hidden email]>
Reply | Threaded
Open this post in threaded view
|

Re: AJAX, Lasso 9.0, Filemaker: How does the Inline fit in?

Tom W Robinson
Hi Brad,

Thanks for the info. Sounds like good advise.   Do you have any snippets of code demonstrating Lasso, JQuery and Filemaker as a datasource?

Thanks!

Tom
Reply | Threaded
Open this post in threaded view
|

Re: AJAX, Lasso 9.0, Filemaker: How does the Inline fit in?

Sean Stephens-2
Tom (et al)

I should also note: this is one place where we do not intend to put immediate energy (if ever). Quite honestly, those who use jQuery (or equivalent) have found, as Brad has noted, that these other libraries are significantly more complete than LJAX, which is limited is scope and usefulness. It was an experiment by an older development team during the early days of AJAX awareness which was rarely used in historical production.

There are very, very few people (none, that I know of) who didn't trip directly from LJAX into jQuery and not look back. I doubt you'll find many people or examples anywhere of its usage. It is, "deprecated by popularity (or lack thereof)".

I'd love to see more examples of usage myself of Lasso and jQuery.

Sean Stephens
CEO
LassoSoft Inc.
http://www.lassosoft.com

On 2011-12-23, at 1:33 PM, Tom W Robinson wrote:

> Hi Brad,
>
> Thanks for the info. Sounds like good advise.   Do you have any snippets of
> code demonstrating Lasso, JQuery and Filemaker as a datasource?
>
> Thanks!
>
> Tom
>
> --
> View this message in context: http://lasso.2283332.n4.nabble.com/AJAX-Lasso-9-0-Filemaker-How-does-the-Inline-fit-in-tp4223734p4229461.html
> Sent from the Lasso - Talk mailing list archive at Nabble.com.
> #############################################################
> This message is sent to you because you are subscribed to
>  the mailing list Lasso
> [hidden email]
> To unsubscribe, E-mail to: <[hidden email]>
> Send administrative queries to  <[hidden email]>

#############################################################
This message is sent to you because you are subscribed to
  the mailing list Lasso
[hidden email]
To unsubscribe, E-mail to: <[hidden email]>
Send administrative queries to  <[hidden email]>
Reply | Threaded
Open this post in threaded view
|

Re: AJAX, Lasso 9.0, Filemaker: How does the Inline fit in?

Robert Carpenter
In reply to this post by Tom W Robinson
Tom-

The good news is that your datasource shouldn't matter much when using jquery/ajax - your ajax scripts talk to lasso, and then lasso talks to filemaker (or mysql, or whatever). It can be helpful to think of ajax as just another way to make requests from the client to the server (because that's what it is :-).

So to address the question in the subject line, the inline fits in with Ajax requests the same way it does for normal requests from the browser - either send a request to your lasso server, and then your lasso code uses inlines and other code to assemble an appropriate response.

Jquery is a great library - it really helps smooth out the rough edges of doing javascript development and working with the DOM in various browsers. But at the end of the day, you're still doing javascript and DOM work, so I'd recommend getting yourself a good foundation with js/DOM along with the specifics of implementing jquery.

Some good books/resources:

- Javascript: The Definitive Guide - David Flanagan
probably the best overall js book out there, if you hear someone talking about "the rhino book", this is what they're referring to. 6th edition includes stuff on jquery and other libraries.

- DOM Scripting/Bulletproof Ajax - Jeramey Keith
These are getting a bit old, but I found both quite helpful and accessible, esp if you come from a design background

- Javascript: The Good Parts - Douglas Crockford
A little more advanced, but helps outline best practices and things to watch out for with our quirky friend Javascript. FWIW, Crockford invented JSON

You'll also want to check out some of the good developer tools out there:

The Firefox plugin Firebug is awesome, and there are other developer tools for different browsers - chrome, IE, Safari.

jslint.com can help check your code for bugs and typos

jsbin.com is a cool online prototyping environment

jsfiddle.net serves a similar purpose

Finally, the validators provided by the W3C and others can help track down issues - javascript works best with clean, valid, semantic markup, these tools can help identify problems.

Hope that helps - have fun!

-Robert-

On Dec 23, 2011, at 10:33 AM, Tom W Robinson wrote:

> Hi Brad,
>
> Thanks for the info. Sounds like good advise.   Do you have any snippets of
> code demonstrating Lasso, JQuery and Filemaker as a datasource?
>
> Thanks!
>
> Tom
>
> --
> View this message in context: http://lasso.2283332.n4.nabble.com/AJAX-Lasso-9-0-Filemaker-How-does-the-Inline-fit-in-tp4223734p4229461.html
> Sent from the Lasso - Talk mailing list archive at Nabble.com.
> #############################################################
> This message is sent to you because you are subscribed to
>  the mailing list Lasso
> [hidden email]
> To unsubscribe, E-mail to: <[hidden email]>
> Send administrative queries to  <[hidden email]>

#############################################################
This message is sent to you because you are subscribed to
  the mailing list Lasso
[hidden email]
To unsubscribe, E-mail to: <[hidden email]>
Send administrative queries to  <[hidden email]>
Reply | Threaded
Open this post in threaded view
|

Re: AJAX, Lasso 9.0, Filemaker: How does the Inline fit in?

Brad Lindsay-2
In reply to this post by Tom W Robinson
On Dec 23, 2011, at 1:33 PM, Tom W Robinson wrote:
> Hi Brad,
>
> Thanks for the info. Sounds like good advise.   Do you have any snippets of
> code demonstrating Lasso, JQuery and Filemaker as a datasource?

If you know how to write a page that gets data out of a Filemaker database and creates HTML, then write that page. The thing about AJAX is that page will be called using JavaScript instead of through the browser.

Now, jQuery has several ways to make AJAX requests which are documented here: http://api.jquery.com/category/ajax/ (Some of the functions listed on the link are utility functions, they're not all for making requests.)

The $.ajax() method is the most complex / flexible method, allowing you complete control over your request.

The simpler methods are $.get(), $.post(), and $(...).load().

Here is a quick example (adjust your inline / records / field code):

The page called by an AJAX request, call it ajax_items.lasso
============================================================
<?lasso
    local(category) = action_param('c')
   
    inline(//Query to find products by #category\\)
    records
?>

<li id="[field('product_id')">[field('product_name')]</li>

<?lasso
    /records
    /inline
?>
============================================================



Your original page that gets loaded, call it index.lasso
============================================================
<!DOCTYPE html>
<html>
<head>
    <title>Products By Category</title>

<script type="text/javascript" charset="utf-8" src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>

    <script type="text/javascript">
    <!--
        function loadProducsFor(category) {
            $("#product_list").load('ajax_items.lasso', {c: category});
        }
    -->
    </script>
</head>
<body>
    <input type="button" value="Category A" onclick="loadProducsFor('a')" />
    <input type="button" value="Category B" onclick="loadProducsFor('b')" />
    <input type="button" value="Category C" onclick="loadProducsFor('c')" />
    <hr />
    <ul id="product_list"></ul>
</body>
</html>
============================================================

So, on this page, I'm loading jQuery from Google's Content Delivery Network (CDN). I have some buttons that when clicked call the function "loadProducsFor()" which update <ul id="product_list">.

Let's look at the "loadProducsFor()" function. jQuery is mostly about finding something ($("#product_list")) and then doing something with it (.load(...)). To find an HTML element, you can use CSS selectors (you can read more about how to select elements in jQuery documentation). In this case, #product_list gets me the unordered list with that as its ID.

I'm then calling the $().load() function on it, which is a jQuery convenience function that creates an AJAX request and puts the resulting HTML back into the object selected. The first parameter passed to .load() is the URL for the request. In this case I'm assuming both files are in the same directory. The second argument in .load is a JavaScript map that allows you to specify what [action_params] get passed along with the request. Since the resulting page is expecting information in [action_param('c')], I have a map with one key (c) that gets the data stored in the variable "category" that gets passed to "loadProducsFor" function.


For a more complex example, using the "$.ajax" jQuery function and passing JSON data instead of HTML, see the following: http://www.lassosoft.com/A-guide-to-using-Lasso-9-and-jQuery


Hope That Helps,
Brad
#############################################################
This message is sent to you because you are subscribed to
  the mailing list Lasso
[hidden email]
To unsubscribe, E-mail to: <[hidden email]>
Send administrative queries to  <[hidden email]>
Reply | Threaded
Open this post in threaded view
|

Re: AJAX, Lasso 9.0, Filemaker: How does the Inline fit in?

Tom W Robinson
Hi Brad,

Thanks so much!  That is exactly what I was looking for.  Thanks for the guidance.

Merry Christmas,

Tom
On Dec 24, 2011, at 6:13 AM, Brad Lindsay-2 [via Lasso] wrote:

On Dec 23, 2011, at 1:33 PM, Tom W Robinson wrote:
> Hi Brad,
>
> Thanks for the info. Sounds like good advise.   Do you have any snippets of
> code demonstrating Lasso, JQuery and Filemaker as a datasource?

If you know how to write a page that gets data out of a Filemaker database and creates HTML, then write that page. The thing about AJAX is that page will be called using JavaScript instead of through the browser.

Now, jQuery has several ways to make AJAX requests which are documented here: http://api.jquery.com/category/ajax/ (Some of the functions listed on the link are utility functions, they're not all for making requests.)

The $.ajax() method is the most complex / flexible method, allowing you complete control over your request.

The simpler methods are $.get(), $.post(), and $(...).load().

Here is a quick example (adjust your inline / records / field code):

The page called by an AJAX request, call it ajax_items.lasso
============================================================
<?lasso
    local(category) = action_param('c')
   
    inline(//Query to find products by #category\\)
    records
?>

<li id="[field('product_id')">[field('product_name')]</li>

<?lasso
    /records
    /inline
?>
============================================================



Your original page that gets loaded, call it index.lasso
============================================================
<!DOCTYPE html>
<html>
<head>
    <title>Products By Category</title>

<script type="text/javascript" charset="utf-8" src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>

    <script type="text/javascript">
    <!--
        function loadProducsFor(category) {
            $("#product_list").load('ajax_items.lasso', {c: category});
        }
    -->
    </script>
</head>
<body>
    <input type="button" value="Category A" onclick="loadProducsFor('a')" />
    <input type="button" value="Category B" onclick="loadProducsFor('b')" />
    <input type="button" value="Category C" onclick="loadProducsFor('c')" />
    <hr />
    <ul id="product_list"></ul>
</body>
</html>
============================================================

So, on this page, I'm loading jQuery from Google's Content Delivery Network (CDN). I have some buttons that when clicked call the function "loadProducsFor()" which update <ul id="product_list">.

Let's look at the "loadProducsFor()" function. jQuery is mostly about finding something ($("#product_list")) and then doing something with it (.load(...)). To find an HTML element, you can use CSS selectors (you can read more about how to select elements in jQuery documentation). In this case, #product_list gets me the unordered list with that as its ID.

I'm then calling the $().load() function on it, which is a jQuery convenience function that creates an AJAX request and puts the resulting HTML back into the object selected. The first parameter passed to .load() is the URL for the request. In this case I'm assuming both files are in the same directory. The second argument in .load is a JavaScript map that allows you to specify what [action_params] get passed along with the request. Since the resulting page is expecting information in [action_param('c')], I have a map with one key (c) that gets the data stored in the variable "category" that gets passed to "loadProducsFor" function.


For a more complex example, using the "$.ajax" jQuery function and passing JSON data instead of HTML, see the following: http://www.lassosoft.com/A-guide-to-using-Lasso-9-and-jQuery


Hope That Helps,
Brad
#############################################################
This message is sent to you because you are subscribed to
  the mailing list Lasso
<a href="x-msg://1377/user/SendEmail.jtp?type=node&amp;node=4231255&amp;i=0" target="_top" rel="nofollow" link="external">[hidden email]
To unsubscribe, E-mail to: <<a href="x-msg://1377/user/SendEmail.jtp?type=node&amp;node=4231255&amp;i=1" target="_top" rel="nofollow" link="external">[hidden email]>
Send administrative queries to  <<a href="x-msg://1377/user/SendEmail.jtp?type=node&amp;node=4231255&amp;i=2" target="_top" rel="nofollow" link="external">[hidden email]>



If you reply to this email, your message will be added to the discussion below:
http://lasso.2283332.n4.nabble.com/AJAX-Lasso-9-0-Filemaker-How-does-the-Inline-fit-in-tp4223734p4231255.html
To unsubscribe from AJAX, Lasso 9.0, Filemaker: How does the Inline fit in?, click here.
NAML