A javascript framework I wrote

Discussion in 'Programming & Software Development' started by yoink, Oct 20, 2008.

  1. OP
    OP
    yoink

    yoink Member

    Joined:
    Feb 19, 2002
    Messages:
    3,516
    You can set the resource path in PAX, to point to where PAX is, so at the start of your JS code, add a line that says:

    Code:
    pax.resourcePath = '/app01/pax/resource/';
    As for the name and ID problem, I'll have to get back to you tonight, perhaps you can post some example code?
     
  2. OP
    OP
    yoink

    yoink Member

    Joined:
    Feb 19, 2002
    Messages:
    3,516
    Hmmm... It works fine for me, with different ID and Name, eg:

    Code:
    <html>
    	<head>
    		<style type='text/css'>@import url( /pax/resource/css/pax_consolidated.css );</style>
    	</head>
    	<body>
    		<script src='/pax/pax_dev.js' type='text/javascript'></script>
    		<input type='text' name='myname' id='different'/>
    		<script>
    			pax.load.onloaded( function() {
    				pax.widget.datePick.init( $('different'), { dateFormat: 'd-m-Y' } );
    			} );
    		</script>
    	</body>
    </html>
    Works, maybe you can post your code?
     
  3. dukestar

    dukestar Member

    Joined:
    May 4, 2002
    Messages:
    827
    Location:
    Sydney
    ok seems to be working now, maybe it was too late in the afternoon for me!

    I have used the resourcePath and it works fine. I had to update the style sheet though. It might be worthwhile referencing the images relatively from where the css file is located rather than from the root.

    for example

    .pButtonNoChrome.widget.datePick {
    width: 16px;
    height: 14px;
    background-image: url( '/pax/resource/img/datepick_icon.gif' );
    }

    could be

    .pButtonNoChrome.widget.datePick {
    width: 16px;
    height: 14px;
    background-image: url( '../img/datepick_icon.gif' );
    }

    that way however many subdirectories the application is located in it will always work.
     
  4. OP
    OP
    yoink

    yoink Member

    Joined:
    Feb 19, 2002
    Messages:
    3,516
    That's a great suggestion, thanks! :thumbup:
    The CSS is one thing I will be working on in the next few months, before I reach v1.0 release :)
    Edit: Having said that, it is being used in production systems, so I'm quite happy with the state it is in :)
     
    Last edited: Oct 23, 2008
  5. deepspring

    deepspring Member

    Joined:
    Jul 8, 2002
    Messages:
    3,601
    Location:
    Maitland, NSW
    Very nice framework!

    If I get another job doing web design, I'll definitely try to make use of it.
     
  6. OP
    OP
    yoink

    yoink Member

    Joined:
    Feb 19, 2002
    Messages:
    3,516
    Thanks! :D
    Feel free to ask any questions about it here, or perhaps post in the PAX Forums :thumbup:
     
  7. Jadlak

    Jadlak Member

    Joined:
    May 25, 2002
    Messages:
    88
    Location:
    Brisbane, 4116
    Maybe a tooltip on click might appease peoples curiosity without bugging them. But yeah :thumbup: good job.
     
  8. OP
    OP
    yoink

    yoink Member

    Joined:
    Feb 19, 2002
    Messages:
    3,516
    Good idea, I'll put that into the example :thumbup:
     
  9. ipAlien

    ipAlien Member

    Joined:
    Apr 18, 2005
    Messages:
    1,155
    Location:
    Just an IP & Subnet away!
    With the data grid, do you have to use JSON to load the data?
    I guess what I'm asking is what other methods or formats can one use?
     
  10. OP
    OP
    yoink

    yoink Member

    Joined:
    Feb 19, 2002
    Messages:
    3,516
    It's only json / ajax, (by specifying a URL), for the data grid. What sort of data are you hoping to load?
    I am looking at different loading methods, and would be keen to hear some real life situations! :)
     
  11. rockuman_ex

    rockuman_ex Member

    Joined:
    Apr 3, 2002
    Messages:
    3,874
    Location:
    Brisbane
    can be handy for me.

    subscribed! :D
     
  12. OP
    OP
    yoink

    yoink Member

    Joined:
    Feb 19, 2002
    Messages:
    3,516
    If you end up using it in something, please post the link :)
     
  13. rockuman_ex

    rockuman_ex Member

    Joined:
    Apr 3, 2002
    Messages:
    3,874
    Location:
    Brisbane
    will do :thumbup:

    does your pax able to post form without leaving the page? and what about $_Files?

    i couldn't find any of the examples on your site regarding this?
     
  14. OP
    OP
    yoink

    yoink Member

    Joined:
    Feb 19, 2002
    Messages:
    3,516
    Yes, it definately does, as a matter of fact, it is one of the key features, yet I somehow thought it so trivial, that I left out an example :o
    I will post up an example later...
     
  15. rockuman_ex

    rockuman_ex Member

    Joined:
    Apr 3, 2002
    Messages:
    3,874
    Location:
    Brisbane
    cool.. about time i leave prototype :D
     
  16. nathanblogs

    nathanblogs Member

    Joined:
    Mar 31, 2005
    Messages:
    3,079
    I love the auto-complete calendar :D, will probably add it to some of my sites :D
     
  17. OP
    OP
    yoink

    yoink Member

    Joined:
    Feb 19, 2002
    Messages:
    3,516
    Hmmm... example will have to come tomorrow, sorry :(
     
  18. OP
    OP
    yoink

    yoink Member

    Joined:
    Feb 19, 2002
    Messages:
    3,516
    Well, it's almost tomorrow, here it is :)
    Code:
    <?php
    //	Form was submitted using AJAX - provide a response...
    if( isset($_REQUEST['ajaxSubmit'])) {
    	header('Content-type: application/x-json');
    	$r = $_REQUEST;
    	print "{'message': 'You submitted via ajax!', 'name': '" . $r['myname'] . "', 'email': '". $r['email'] ."'}";
    
    } else {
    ?>
    <div>
    	<form name='myForm' id='myForm' action='test_form.php'>
    		<label for='myname'>Name: </label><input type='text' name='myname' id='myname' value='John Smith'/><br/>
    		<label for='email'>Email: </label><input type='text' name='email' id='email' value='test@test.com'/><br/>
    		<input type='submit' value='Submit' id='submit_button'><span id='spin'></span><br/>
    	</form>
    </div>
    
    <script type="text/JavaScript" src="/pax/pax_dev.js"></script>
    <script>
    	pax.load.onloaded( function() {
    		//	Disable normal form submit
    		pax.event.bind( $('myForm'), 'submit', function(e) {
    			if( e.preventDefault )e.preventDefault();	//	Most browsers
    			else e.returnValue = false;					//	IE
    			return false;								//	Fallback?
    		} );
    		//	Bind submit button to use ajax
    		pax.event.bind( $('submit_button'), 'click', function() {
    			var allFields = pax.validate.allFields( 'myForm' );
    			var values = {};
    			for( var i in allFields ) {
    				var field = allFields[i];
    				values[field.name] = pax.form.getFieldValue( field );
    			}
    			//	To tell the server we submitted via ajax.
    			values['ajaxSubmit'] = true;
    			
    			pax.post( 'test_form.php', pax.postString( values ), function( xml, txt, url ) {
    				alert( txt );
    			}, 'Ajax submit example' );
    			
    			return false;
    		} );
    	} );
    </script>
    <? } ?>
    It wasn't quite a straight forward as I remembered, but still quite workable ;)

    Edit: $_FILES is a PHP function, how would you see this being handled in pax? Do you have an example of your expected behaviour?
     
    Last edited: Nov 25, 2008
  19. rockuman_ex

    rockuman_ex Member

    Joined:
    Apr 3, 2002
    Messages:
    3,874
    Location:
    Brisbane
    ah... missed your post :p

    the form doesn't work in firefox?

    how do you handle file fields?
     
  20. OP
    OP
    yoink

    yoink Member

    Joined:
    Feb 19, 2002
    Messages:
    3,516
    Works fine for me in both IE and FF, what do you end up seeing? Did you try my link here?

    You cannot submit files via ajax, that is impossible, however there are solutions where you use an iframe trick, or better yet, a flash object (which will also allow multiple fields to be uploaded at the same time); I think I may update pax.form to handle what you're asking here via the iframe trick, and then perhaps a plugin for the flash uploader :)
    It won't be done this weekend, but give me a couple of days, and I should have something for you ;)
     

Share This Page

Advertisement: